function gmtime()
{
return (time() - date('Z'));
}
function server_timezone()
{
if (function_exists('date_default_timezone_get'))
{
return date_default_timezone_get();
}
else
{
return date('Z') / 3600;
}
}
function local_mktime($hour = NULL , $minute= NULL, $second = NULL, $month = NULL, $day = NULL, $year = NULL)
{
$timezone = isset(
{1}
SESSION['timezone']) ?
{1}
SESSION['timezone'] : $GLOBALS['_CFG']['timezone']; $time = mktime($hour, $minute, $second, $month, $day, $year) - $timezone * 3600; return $time;}function local_date($format, $time = NULL){ $timezone = isset(
{1}
SESSION['timezone']) ?
{1}
SESSION['timezone'] : $GLOBALS['_CFG']['timezone']; if ($time === NULL) { $time = gmtime(); } elseif ($time <= 0) { return ''; } $time += ($timezone * 3600); return date($format, $time);}function gmstr2time($str){ $time = strtotime($str); if ($time > 0) { $time -= date('Z'); } return $time;}function local_strtotime($str){ $timezone = isset(
{1}
SESSION['timezone']) ?
{1}
SESSION['timezone'] : $GLOBALS['_CFG']['timezone']; $time = strtotime($str) - $timezone * 3600; return $time;}function local_gettime($timestamp = NULL){ $tmp = local_getdate($timestamp); return $tmp[0];}function local_getdate($timestamp = NULL){ $timezone = isset(
{1}
SESSION['timezone']) ?
{1}
SESSION['timezone'] : $GLOBALS['_CFG']['timezone']; if ($timestamp === NULL) { $timestamp = time(); } $gmt = $timestamp - date('Z'); // 得到該時間的格林威治時間 $local_time = $gmt + ($timezone * 3600); // 轉換爲用戶所在時區的時間戳 return getdate($local_time);}