0

I wrote a web application that used the following to store a date:

$event->date = mktime(0, 0, 0, $month, $day, $year);

where $month, $day, $year came from dropdown selectors i.e. where integer values. So I was storing dates represented by midnight of the day the user chose.

This weekend we had daylight savings and now all events added since the last time the clocks were changed are now displaying date('D jS M Y' ,$event->date) as the day before.

My question is two-fold:

  • how do I fix the current dates in the database so that they are output as the correct day? Should I add an hour to all the times in the DB in one go?

  • how should I store the dates going forward from this point? Should I add an hour to midnight like this? $event->date = mktime(1, 0, 0, $month, $day, $year);

andyg1
  • 1,455
  • 3
  • 13
  • 21

1 Answers1

0

1) Use some SQL query to update your timestamps 2) You should use UTC time or epoch all the time and do the locale conversion on-the-fly at client requests. It'll make you dates locale-free.

Gianluca Ghettini
  • 11,129
  • 19
  • 93
  • 159