daylight savings time messing up date calculation
Posted: Mon Feb 23, 2009 6:30 pm
I need to calculate the number of days between two dates as an integer. Daylight savings time screws up the number of days. My code is as follows:
$firstdate = strtotime($courseset["startdate"]);
$seconddate = strtotime($courseset["enddate"]);
$days = ($seconddate - $firstdate) / (60 * 60 * 24);
If I add the following to force $days to be an integer, it doesn't round correctly:
$days = (int) $days;
$firstdate = strtotime($courseset["startdate"]);
$seconddate = strtotime($courseset["enddate"]);
$days = ($seconddate - $firstdate) / (60 * 60 * 24);
If I add the following to force $days to be an integer, it doesn't round correctly:
$days = (int) $days;