Reputation: 89
Here's my PHP code:
echo date('M j y g:i:A');
This doesn't display correct time. why?
Upvotes: 0
Views: 1755
Reputation: 146350
fix the time zone in php.ini or in the code itself
Add something like this to your php.ini file date.timezone = "Asia/Manila", that will set the default without having you put in the date_default_timezone_set('Asia/Manila'); on every file that uses time functions
Upvotes: 1
Reputation: 7656
Insert this at the very top of your code:
date_default_timezone_set('Asia/Manila');
Upvotes: 3
Reputation: 26380
It's most likely echoing the time on the server, which is often GMT. If you're time zone is GMT+5, you may need to add 5 hours to the timestamp.
For 5 hours...
$offset = 5 * 60 * 60;
echo date('M j y g:i:A', time() + $offset);
Upvotes: 0