Copy link to clipboard
Copied
I've built a CRM for an international company. We have users in every timezone. There's a field for next appointment day and time. Each user in each part of the world will see these appointment times as GMT now. What I'd like to do is detect the users time zone and run a conversion so that when a user says Nov 10, 2012 at 10AM the time is automatically converted to GMT then stored in the appointment field. I've found several slick Java appointment date and time widgets that will crate a pop up calendar and time to populate the field with data in the standard mySql date format, but I haven't been able how to use PHP date functions to read the local machine timezone, convert the data entered into the field, then calculate the diference and update the hours value to GMT.
If anyone has any ideas I'd appreciate it. Once the value is GMT I have no problem converting it back to local time for display in the CRM.
If you have any better ideas let me know.
Thanks.
Copy link to clipboard
Copied
I don't know how to read the machine timezone but doubt that you really want to do that anyway because it is extremely likely to be wrong. You can easily determine the time zone of the ip address that is being used, but again, this may also not be the correct timezone for the task. And what happens when the employee is in China but scheduling a meeting for Australia?
So, if I understand your issue, the way I think I would handle it is to let the user select both a default timezone as well as apply a timezone to particular appointment entries, or to particular days. This solution may not seem as slick, but I suspect that juggling the timezones behind-the-scene might be a huge headache.
I would also use the PHP dateTime and DateTimeZone classes instead of the PHP date functions.
Copy link to clipboard
Copied
Can you let the user store their preferred timezone with their profile? That's how most CMS's would handle it.