When we use date and gmdate, they may get different date based on your time zone. For example,
php code:
echo date_default_timezone_get ().PHP_EOL;
echo 'Result with date("M d Y H:i:s"):'.PHP_EOL;
echo date("M d Y H:i:s").PHP_EOL;
echo 'Result with gmdate("M d Y H:i:s"):'.PHP_EOL;
echo gmdate("M d Y H:i:s").PHP_EOL;
Result:
Asia/Tokyo
Result with date("M d Y H:i:s"):
Feb 13 2013 09:00:05
Result with gmdate("M d Y H:i:s"):
Feb 13 2013 00:00:05
Reason:
1. date is that the time returned is your time zone. Usually you may change it by using date_default_timezone_set('your timezone');
2. gmdate is that the time returned is Greenwich Mean Time (GMT).
No comments:
Post a Comment