Reputation: 886
What is likely to be going on when the time on the server is out by 12 hours? I am working on a site for a friend, and noticed that although the server is in our timezone, it is 12 hours behind us when writing records to the DB. So I did the checks like so:
<?php echo(gmstrftime("It is %a on %b %d, %Y, %X time zone: %Z",time()));
phpinfo();
?>
result:
It is Thu on Jul 21, 2011, 04:46:46 time zone: GMT
...
date
date/time support enabled
"Olson" Timezone Database Version 2010.15
Timezone Database internal
Default timezone Pacific/Auckland
Directive Local Value Master Value
date.default_latitude 31.7667 31.7667
date.default_longitude 35.2333 35.2333
date.sunrise_zenit 90.583333 90.583333
date.sunset_zenith 90.583333 90.583333
date.timezone Pacific/Auckland Pacific/Auckland
Ask you can see, PHP reports 4:46 am. It's really 4:46pm here. It reports GMT as the Timezone, but the PHPinfo reports Pacific/Auckland as the Timezone (GMT+12).
I asked the webhost what was going on. They weren't sure, as the system's time was correct. And there are no other php.ini files being introduced.
Ideas?
Upvotes: 0
Views: 268
Reputation: 1602
gmstrftime reports GMT time, which looks correct to me. You need strftime to get your local (AKL) time. php.ini probably has its timezone set to AKL, which again is correct. The correct question is "what does strftime (or any other PHP current time function) report?"
Upvotes: 1
Reputation: 88378
gmstrftime
by its very nature reports times in GMT. That is what the gm
is for. :)
Upvotes: 0