How to keep accurate time (daylight saving time) for a web application?

Ok, this might be a simple question, but I still have a working solution, so anyone who can help in advance thanks.

Consider the following scenario: we have a web application running on MySQL (if you need to know), time dependent, the application says, which sends an email at a user specified time. Now each user has set their own time zone / city, and the servers run in UTC for simplicity. The exact time will be server time + time zone + daylight saving time. The user wants the letter to reach him on January 4, 2010 at 17:00. The question is, how do you get the right daylight? What is the value of this user in the region that is watching DST, if he or she has not already watched it?

My first impulse would be to find a web service that, given the current time zone / city, will give you the correct daylight saving time. Until I found it. I am discouraged by the second idea that I should establish rules for daylight saving time, since these changes change from year to year, and in some countries more than a day or two.

Any help is greatly appreciated.

+2


source to share


2 answers


If your programming language doesn't support timezone logic, then you don't need to program the rules yourself. You just need to program the zoneinfo database support .



+1


source


Store your dates in seconds from Jan 1, 1970 GMT in your database and you will always have a deal. When the user logs in to their time, convert it accordingly using the correct time zone settings and you're done.

Your servers are already running without time zones, so when the time is right, it's easy for you to choose.



Here's some code to convert the timezone to LISP:

0


source







All Articles