Search code examples
phptimezonetimestamp-with-timezone

PHP timezone issuse with Pacific/Auckland - Getting different value


    $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?


Solution

  • 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.