【发布时间】:2014-09-16 13:10:45
【问题描述】:
PHP 是否会自动将标准时间转换为夏令时?例如,我们需要PST[$toTimezone]timezone 的时间,但 PHP 正在返回 PDT。下面是我们正在使用的示例函数。
$fromTime = '2014-09-16 06:45:45';
$fromTimezone = 'GMT';
$toTimezone = 'PST';
function x($fromTime, $fromTimezone, $toTimezone,$format = 'l, F jS, Y g:i A T') {
$fromTimezone = new \DateTimeZone($fromTimezone);
$toTimezone = new \DateTimeZone($toTimezone);
$orgTime = new \DateTime($fromTime, $fromTimezone);
$toTime = new \DateTime($orgTime->format("c"));
$toTime->setTimezone($toTimezone);
return $toTime->format($format);
}
问候, Vamsi Krishna Grandhi
【问题讨论】:
-
其实PHP是看服务器时间的。
标签: php date datetime time timezone