Possible Duplicate:
How do you handle timezone difference calculation in PHP?
On yesterday's change to DST in Sweden, I run into a issue with some code I made. I'm using the PHP DateTime, DateTimeZone, DateTimePeriod etc, and do not agree with the results.
What is your opiontion on number of days between these dates, and the number of hours ?
"Sun, 28 Oct 2012 01:00:00 +0200"
"Mon, 29 Oct 2012 00:00:00 +0100"
PHP tells me it is 0 days and 23 hours. I would say it is 0 days, but 24 hours.
Update: The timezone is "Europe/Stockholm", so it is the same for both dates.
To reproduce:
$timezone = new DateTimeZone("Europe/Stockholm");
$date1 = new DateTime("Sun, 28 Oct 2012 01:00:00", $timezone);
$date2 = new DateTime("Mon, 29 Oct 2012 00:00:00", $timezone);
$date1->setTimezone($timezone);
$date2->setTimezone($timezone);
$diff = $date1->diff($date2);
var_dump($diff);
Update 2:
Using Java and JodaTime class, it gives me 24 hours. So appearently the correct answer is not obvious :)