Question

Okay this may be a simple question but I have yet to come with a working solution, so to anyone who can help thanks in advance.

Consider the following scenario: We have a web-application running on MySQL (if you need to know) that is time dependent say an application that sends an email at the user specified time. Now every user has set his proper timezone/city and the servers are running on UTC for simplicity. The accurate time would be server time + timezone + daylight saving. The user wants the email to reach him on Jan 4 2010 5:00 pm his time. My question would be how to get the correct daylight saving? Meaning is this user in a region that observes DST if so did he/she observe it or not yet?

My first impulse would be to find a web-service that given the current timezone/city would give you the proper daylight saving. So far i have not found one. I am discouraged by the second idea, that I have to set rules for DST since these change from year to year and in some countries by more than a day or two.

Any help greatly appreciated.

Was it helpful?

Solution

If your programming language doesn't have support for fancy time zone logic, you don't have to program the rules by yourself. You just need to program support for the zoneinfo database.

OTHER TIPS

Store your dates as seconds since Jan 1, 1970 GMT in your database and you'll always have the time dealt with. When the user enters in his time, convert it as appropriately using the correct timezone settings and you're done.

Your servers are already running without timezones so when the time comes it's an easy select.

Here's some code to do timezone conversion in LISP:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top