📜 ⬆️ ⬇️

PHP followed in the footsteps of Munchausen: on October 26, he has 25 hours a day !!!

I stumbled upon an annoying error in PHP time functions (tested on versions 5.1.2 and 4.3.3)
Who has newer versions installed - please check. And then for the sake of a single check, reinstall the crowbars ... Under the code for testing.

<?php
echo strtotime("2008-10-26")-strtotime("2008-10-25")."\n";
echo strtotime("2008-10-27")-strtotime("2008-10-26")."\n";
echo strtotime("2008-10-28")-strtotime("2008-10-27")."\n";

$time=strtotime("2008-10-25");
$end_time=strtotime("2008-10-28");
while($time<$end_time)
{ echo $time."\t";
echo date('Ymd H:i:s',$time)."\n";
$time+=86400; // 60sec * 60min * 24hour
}
?>


Result:

86400
90000
86400
1224871200 2008-10-25 00:00:00
1224957600 2008-10-26 00:00:00
1225044000 2008-10-26 23:00:00
1225130400 2008-10-27 23:00:00
')
UPDATE: For those who are too lazy to read comments - this turns out to be not a bug, this is a feature! Associated with summer-winter time.

Source: https://habr.com/ru/post/20169/


All Articles