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 Weekday'))); // 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 weekday'); var_dump($date1->format('Y-m-d H:i:s')); // Uncorrect, lost time: 2020-11-30 00:00:00
Output for 5.3.6 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.29, 7.4.0 - 7.4.21, 8.0.0 - 8.0.8
string(19) "2020-11-28 12:33:00" string(19) "2020-11-30 00:00:00" string(19) "2020-11-28 12:33:00" string(19) "2020-11-30 00:00:00"
Output for 5.3.0 - 5.3.5
string(19) "2020-11-28 12:33:00" string(19) "2020-11-30 00:00:00" string(19) "2020-11-28 12:33:00" string(19) "2020-11-30 12:33:00"
Output for 5.2.0 - 5.2.17
string(19) "2020-11-28 12:33:00" string(19) "2020-11-30 00:00:00" string(19) "2020-11-28 12:33:00" string(19) "2020-11-27 12:33:00"
Output for 5.1.1 - 5.1.6
string(19) "2020-11-28 12:33:00" string(19) "1970-01-01 01:00:00" Fatal error: Class 'DateTime' not found in /in/m0UbY on line 10
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/m0UbY on line 18
Process exited with code 255.
Output for 5.0.0 - 5.0.5
string(19) "2020-11-28 12:33:00" string(19) "1970-01-01 00:59:59" Fatal error: Class 'DateTime' not found in /in/m0UbY on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
string(19) "2020-11-28 12:33:00" string(19) "1970-01-01 00:59:59" Fatal error: Cannot instantiate non-existent class: datetime in /in/m0UbY on line 10
Process exited with code 255.
Output for 4.3.1
string(19) "2020-11-28 12:33:00" string(19) "1970-01-01 00:59:59" Fatal error: Cannot instantiate non-existent class: datetime in /in/m0UbY on line 10

preferences:
4335.76 ms | 467 KiB | 5 Q