2

I have a system that generates reports and sends out an email to users.

Users can choose what time they want the reports sent, I store their desired time in mysql.

The servers run in GMT/UTC and I store their requested report time in the database in GMT/UTC as well.

When they pick the time they want off the webpage I convert the PHP timezone (like Asia/Hong_Kong or America/Chicago) and save the time they want their report into mysql in GMT/UTC.

I then query the database and send their report at their requested time. Works fine this way, until... daylight savings time kicks in.

Of course not every place has daylight savings, and not every place adjusts by the same number of minutes and not on the same date every year and not all places adjust on the same dates of the year.

How can I calculate the correct time, so the system is correct all year?

I am using PHP to store the timezones and storing the date/time in mysql, so these are the two tools I have available.

Drew
  • 24,851
  • 10
  • 43
  • 78
Rob Gunsuka
  • 705
  • 1
  • 5
  • 9
  • Possible duplicate of [How can I detect day light savings automaticaly in PHP?](http://stackoverflow.com/questions/2763935/how-can-i-detect-day-light-savings-automaticaly-in-php) – M O'Connell Sep 12 '16 at 12:11
  • 1
    I think the issue is more complex than that question, as he doesn't simply just want to know if dst is active. – calcinai Sep 12 '16 at 12:13
  • I could build a script in PHP that I run every day, loop over all the PHP timezones - determine if that timezone is currently in daylight savings and store the additional offset in mysql. Then when I query the database I can take the additional offset into consideration. Doesn't seem like a very elegant solution though. – Rob Gunsuka Sep 12 '16 at 12:49

0 Answers0