• I couldn’t post this on WPMU Dev as I am not a paying member any more. I know a lot of people have been asking for multi time zone support for this plugin and WPMU Dev have been saying it’s in the works for the last couple of years. I just wanted to let people know, it’s possible. I have implemented this on a project I have just finished for a client.

    I can’t share the actual code with you as someone has paid to have it done, but I can share the process so hopefully you can figure it out for yourselves.

    This is is the basic process:

    1. Decide how you are determining user’s time zones. I was collecting this when they registered, though you use their IP.

    2. I have both workers and clients in various time zones. I needed to work out the the difference in minutes between the worker and the client. I wrote a function for this and used the PHP DateTime object and DateTimeZone.

    3. The SQL for getting a worker’s schedule from the database is in a function get_worker_break(). This gets both their open and close schedules.

    4. The open and close schedules are in serialized arrays. These will need to be unserialized (maybe_unserialize()).

    5. Have 3 different conditionals set up, one for if the hours go back, one if they go forward and one if they don’t change at all.

    6. Within each of these conditionals, loop through each day and update the start and end key value pairs with the time difference (either add or remove minutes).

    7. Determine if the minutes either stay on the same day (Monday 5pm – 7pm changes to Monday 7pm – 9pm), whether the hours completely change to a different day (Monday 5pm – 7pm becomes Tuesday 12am – 2am) or whether the hours become split between two days (Monday 5pm – 7pm becomes Monday 11pm – Tuesday 1am).

    8. Set up conditionals for each of the different scenarios above and then set the appropriate active, start and end key value pairs for both the open and close hours arrays.

    9. I then serialized these arrays and used them in the get_worker_hours() function.

    10. When booking appointments I wrote them to the database in UTC to keep comparing/querying for simple for checking whether an appointment is already booked.

    Good luck!

    https://www.ads-software.com/plugins/appointments/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘I have successfully implemented multiple time zones on Appointments’ is closed to new replies.