Search code examples
phpunix-timestamp

November 5 and 6 time difference (php)


I was writing a simple code with some date calculations. I ran into an interesting issue; the following code is simply calculating how many hours are there between two dates, and the result should read 24 hours. For different dates I plugged in I come up with 24, but these two dates is 25. Does anyone know why? I have a program that I jump days, and group by stuff in sql by date, and it's a bit annoying that $date+24*60*60; still falls in the same date at 23:00 hours.

<?php

$first = mktime(0, 0, 0,11, 5, 2017);

$second = mktime(0, 0, 0,11, 6, 2017); 

$delta = ($second - $first)/60/60;


echo $delta."<BR>";

?>

Solution

  • Daylight savings time ended in the USA on the 5th. Is that where your timezone is set up?