Suppose this code:
<?php
date_default_timezone_set('UTC');
$time = gmmktime(14, 50, 0, 5, 12, 2013);
echo date('Y-m-d H:i:s O', $time).'<br />';
echo gmdate('Y-m-d H:i:s O', $time).'<br />';
date_default_timezone_set('GMT');
$time = gmmktime(14, 50, 0, 5, 12, 2013);
echo date('Y-m-d H:i:s O', $time).'<br />';
echo gmdate('Y-m-d H:i:s O', $time);
?>
On my local server I get the output:
2013-05-12 14:50:00 +0000
2013-05-12 14:50:00 +0000
2013-05-12 14:50:00 +0000
2013-05-12 14:50:00 +0000
But on production the same code produces:
2013-05-12 10:50:00 -0400
2013-05-12 14:50:00 +0000
2013-05-12 14:50:00 +0000
2013-05-12 14:50:00 +0000
Changing time of the machine doesn't affect the output in any way.
Some info:
$ date +%Z
GMT
$ date +%z
+0000
phpinfo() showed "Olson" Timezone Database Version as 0.system, so I used the command
pecl upgrade timezonedb
and added
extension=timezonedb.so
to php.ini
After restarting the server, the problem has been resolved with the new timezone DB version 2013.3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With