I found something that I canโt explain, maybe someone here can give me a hint.
I have the following test code that prints 2 formatted timestamps, one for 03/31/2013 and one for 03/31/2014, using date()and gmdate():
<?php
function print_date($timestamp, $year) {
$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;
$end_2014 = 1396216800;
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 does the difference in 2014 come from? My first thought is summer time, but why doesnโt it affect 2013? Why is there a difference of 2 hours in 2014, but a difference of 1 hour in 2013?
source
share