Don’t use adding 86400 seconds in real life

Consider the following example:

$date = strtotime('23 Oct 2009 00:00:00');
$end  = strtotime('26 Oct 2009 00:00:00');
while($date < $end )
{
    echo date(&#039;Y-m-d&#039;,$date).PHP_EOL;
    $date += 86400;
 
}
it will output:
2009-10-23
2009-10-24
2009-10-25
2009-10-25
rather than expected:
2009-10-23
2009-10-24
2009-10-25
2009-10-26
This is because of Daylight Saving Time, if you add hours :

it will output:
2009-10-232009-10-242009-10-252009-10-25
rather than expected:2009-10-232009-10-242009-10-252009-10-26
This is because of Daylight Saving Time, if you add hours :

echo date('Y-m-d',$date).PHP_EOL;

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.