簡體   English   中英

PHP strtotime 作為 UTC 時間戳返回?

[英]PHP strtotime to return as UTC timestamp?

它有點嚴重的差異問題。 在我的本地開發人員上。 服務器我正在使用:

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

上面的代碼為我的時區提供了正確的時間戳。 但是,相同的代碼在實時服務器上返回 false。

實時服務器安裝了較低版本的 php,我想這就是問題所在。

我正在尋找的是上述代碼行的替代方案。

我可以使用沒有“UCT”部分的正常 strototime 並添加 2 小時,但寧願讓 PHP 處理時區。

$date 看起來像這樣:2011-05-25 05:48:00

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

代替

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

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 時區數據庫:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM