Reputation: 4345
Everytime I echo time() within my php file it returns an incorrect date. For example echoing time() now would output December 23 2PM when it is December 22nd 11pm. Any ideas? Is it something that needs to be reconfigured in the php settings, my computer macosx is set to the correct date also.
I've set the default time zone and then did phpinfo() and it states the timezone is set to what ever i set it to but it still gives me the same result no matter what time zone I use.
Upvotes: 1
Views: 1970
Reputation: 2412
putenv ('TZ=Asia/calcutta');
strtotime(1293084000(unixtimestamp)); echo date("Y-m-d");
Upvotes: 0
Reputation: 1618
The time() always returns time stamp that is timezone independent (=UTC). Output of time() should be something like this : 1293079226. it won't print like December 23 2PM....
Upvotes: 3
Reputation: 3775
date_default_timezone_set('your timezone');
echo time();
Upvotes: 0
Reputation: 522005
You need to set your timezone!
date_default_timezone_set('Asia/Tokyo');
echo date('Y-m-d H:i:s');
Upvotes: 2
Reputation: 1733
PHP is a server side script, meaning that it is ran from the server. If the date is wrong then it is most likely because the date on the server is wrong, not your computer. If you have access to php.ini then look for the date.timezone setting and make sure it is set to your desired timezone.
Upvotes: 0