I'm looking for the best practice/solution to book a service internationally, using same time in any browser. I don't quite get the logic (and dug around here too).
Use case
- user in Brussels booking lets say a haircut service based in Singapore - he is flying there in a week. He picks 14:00 in the browser datetime control. The browser is, however, set to +1 UTC.
- SG haircut stylist should see the time in his agenda as 14:00 SG time.
- the barber shop owner is traveling at Dubai, and he wants to see his agenda still in SG timezone, despite his browser is temporarily set to +4 UTC.
Basically, all roles must see "barber shop" local time regardless of what TZ they are in, and report back to server in "shop" time.
Server time is UTC, timestamps are in unix seconds. "Shop" TZ is known.
Problem is that I use couple of jquery plugins (datetimepicker and calendar) that utilize browser local time internally, and there are a few thousand lines of code to analyze and fix, making it less supportable - browser in (Bruxelles|any other TZ) for each "new Date()" will get local browser time. There are quite some narrow places as well (as these imaginary "barber shops" are located worldwide and are picked from the map, so target TZ is dynamic).
What is the common practice for that?
Is it easier to
- mock "dynamic" base date in js that does not care of timezone, and feed to plugins
- convert server data to local TZ when loaded to the client
- apply some other solution
Thanks very much
PS I have read best practices - but as I said I'm sort of bound to using specific plugins.
SOLUTION:
I realized that I do not need relative values of these datetimes as I never need to compare books of different "barber shops" timewise (having lat/lng for each "shop" I can still recalc the relative times if needed).
Basically I would only need absolute UTC values regardless of the timezone and in this case unix time (seconds since 1970 UTC) fits perfectly.
Instead of correcting the time by user browser offset at the client, sending it to backend, and fixing it there by the target offset, now I run the whole system on clear UTC dates, both at client and server/db sides, stored and shown to all roles, with only exception to date/time filters, which are bound to local browser clock and not stored anywhere.