Reputation: 8649
I'm building a site that stores date/time values in UTC on the database.
When I display these values, I use javascript to convert them to the current's user timezone. This is working correctly so far.
Now I want to send some information to users by email (something like a reminder), and this should have the date time as well.
I don't want to print the UTC time in the email, and since I'm sending the email from the server I don't have access to the user's current timezone.
What's the best approach to solve this? should I store the timezone of the user whenever he logs in and use that to convert the date?
Any comments are appreciated.
Upvotes: 1
Views: 1426
Reputation: 22261
Yes, you can detect the user's timezone using Javascript, have the Javascript submit that information to the server, and have the server store it as a preference. If the user sometimes changes timezones you could even keep track of which one they are in most frequently and use that one.
Upvotes: 1