php - Different results for date() and gmdate() -


i found can't explain, maybe here can give me hint.

i have following test code, prints 2 formatted timestamps, 1 31.03.2013 , 1 31.03.2014, using date()and gmdate():

<?php  function print_date($timestamp, $year) {   // add timezone offset germany   $timestamp += 3600;   print "in $year\n";   print "date:   " . date('d.m.y h:i:s', $timestamp) . "\n";   print "gmdate: " . gmdate('d.m.y h:i:s', $timestamp) . "\n";   print "\n"; }  $end_2013 = 1364684400; // 31.03.2013 $end_2014 = 1396216800; // 31.03.2014 print_date($end_2013, '2013'); print_date($end_2014, '2014');  print "default timezone: " . date_default_timezone_get() . "\n"; 

the result surprises me:

in 2013 date:   31.03.2013 01:00:00 gmdate: 31.03.2013 00:00:00  in 2014 date:   31.03.2014 01:00:00 gmdate: 30.03.2014 23:00:00  default timezone: europe/berlin 

where difference in 2014 come from? first thought daylight savings time, why doesn't have effect in 2013? why there 2 hours difference in 2014 1 hour difference in 2013?

daylight savings berlin starts at

2013 sunday, 31 march, 02:00  2014 sunday, 30 march, 02:00  

your specified time value each date 00:00 on date, 2013 sunday, 31 march before 2am, no daylight savings; 2014 after 2am on 30th march


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -