PHP strtotime以UTC时间戳返回?

时间:2011-06-08 07:38:47

标签: php timestamp strtotime

它有点严重的差异问题。在我当地的开发。服务器我正在使用:

<?php print strtotime($date." UCT"); ?>

上面的代码为我的时区提供了正确的时间戳。但是,相同的代码在实时服务器上返回false。

实时服务器安装了较低版本的php,我想这就是问题所在。

我正在寻找的是上述代码行的替代方案。

我可以使用正常的strototime而不使用。“UCT”部分并在2小时内添加,但宁愿使用PHP处理时区。

$ date看起来像这样:2011-05-25 05:48:00

2 个答案:

答案 0 :(得分:31)

<?php print strtotime($date." UTC"); ?>

而不是

<?php print strtotime($date." UCT"); ?>

答案 1 :(得分:0)

PHP文档页面上的PHP警告,不支持UCT:

http://www.php.net/manual/en/timezones.others.php

Warning

Please do not use any of the timezones listed here (besides UTC), they only exist for backward compatible reasons.

这是最新的PECL timezon数据库:

http://pecl.php.net/get/timezonedb

相关问题