dongwang3066 2014-08-22 05:28
浏览 45
已采纳

太平洋/奥克兰的PHP时区问题 - 获得不同的价值

    $user_timezone_from =  'UTC';
    $user_timezone_to =  'Pacific/Auckland';
    $date = new DateTime('2015-08-21 14:00', new DateTimeZone($user_timezone_from)); 
    $date->setTimezone(new DateTimeZone($user_timezone_to)); 
    echo $cur_gmt_date = $date->format('Y-m-d H:i:s');

    $date = new DateTime('2015-09-29 14:00', new DateTimeZone($user_timezone_from)); 
    $date->setTimezone(new DateTimeZone($user_timezone_to)); 
    echo $cur_gmt_date = $date->format('Y-m-d H:i:s');

I am getting different results for this.

2015-08-22 02:00:00

2015-09-30 03:00:00 It should be 2015-09-30 02:00:00

Why I got wrong value?

  • 写回答

1条回答 默认 最新

  • dongwu5801 2014-08-22 05:57
    关注

    Wikipedia tells me that on the last Sunday of September there's a DST change in New Zealand. Hence a one hour difference to Summer Time.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?