I have a PHP application that should support time zones. Now I store the date and time values in the database as integers. So here is what I do.
// now create the DateTime object for this time and user time zone
$dtime = new DateTime($date_time, new DateTimeZone($time_zone));
$timestamp = $dtime->format('U');
What I do not understand, even if the person is in New Zealand (Pacific / Auckland), and the application stores this date: 12-24-2010 00:00:00, using the code above, the value is returned as: 1293102000
Then, using the same date / time and setting the time zone to London (Europe / London), I get this timestamp: 1293148800
Why are timestamps different? I thought the timestamp would be the same number of seconds as the same date from the Unix era?
If they are different from each other, this means that when someone searches the database for all records between 12-24-2010 00:00:00 and 12-24-2010 23:59:59 I need to use the users time zone for create timestamps, and I have to use the time zone to create timestamps.
Help!
source
share