![](/img/trans.png)
[英]Can filemtime be compared with strtotime at the daylight savings change?
[英]php strtotime puzzle - daylight savings?
$t = strtotime( '2012-09-21T03:00:00+00:00 America/Chicago' );
$t2 = date('c',$t);
echo $t2;
2012-09-20T23:00:00-04:00
芝加哥的時區是UTC-5,為什么我沒有得到2012-09-20T22:00:00-05:00
的結果?
strtotime
轉換為Unix時間戳。 date
將使用當前時區將時間戳轉換為字符串。 嘗試先設置您的時區。
$t = strtotime( '2012-09-21T03:00:00+00:00 America/Chicago' );
date_default_timezone_set('America/Chicago');
$t2 = date('c',$t);
echo $t2;
這並不能真正回答我的問題,但是我做了以下修復工作:
date_default_timezone_set('America/Chicago');
$t = strtotime( '2012-09-21T03:00:00+00:00' );
$t2 = date('c',$t);
echo $t2;
輸出: 2012-09-20T22:00:00-05:00
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.