问题
Possible Duplicate:
Timezone conversion in php
When a user logs in, I save his/her local timezone in session, and set the default php timezone to it: date_default_timezone_set($_SESSION['timezone']);
For storing time/date into database, I use GMT timestamp.
After user submits a form with a date/time, I use strtotime or mktime to get the timestamp in user's local timezone.
How to convert user local timestamp to GMT timestamp?
回答1:
$second = gmdate('s', $timestamp);
$minute = gmdate('i', $timestamp);
$hour = gmdate('H', $timestamp);
$day = gmdate('d', $timestamp);
$month = gmdate('m', $timestamp);
$year = gmdate('Y', $timestamp);
$gmt = mktime($hour, $minute, $second, $month, $day, $year);
来源:https://stackoverflow.com/questions/9158501/how-to-convert-user-local-timestamp-to-gmt-timestamp