3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = '2020-11-27 12:33:00'; var_dump(date('Y-m-d H:i:s', strtotime($date.' +1 day'))); // Correct: 2020-11-28 12:33:00 var_dump(date('Y-m-d H:i:s', strtotime($date.' +1 day'))); // Uncorrect, lost time: 2020-11-30 00:00:00 $date1 = new DateTime($date); $date2 = new DateTime($date); $date2->modify('+1 day'); var_dump($date2->format('Y-m-d H:i:s')); // Correct: 2020-11-28 12:33:00 $date1->modify('+1 day'); var_dump($date1->format('Y-m-d H:i:s')); // Uncorrect, lost time: 2020-11-30 00:00:00
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.26, 8.0.0 - 8.0.13, 8.1rc1 - rc3
string(19) "2020-11-28 12:33:00" string(19) "2020-11-28 12:33:00" string(19) "2020-11-28 12:33:00" string(19) "2020-11-28 12:33:00"

preferences:
34.77 ms | 460 KiB | 5 Q