3v4l.org

run code in 300+ PHP versions simultaneously
<?php $time = new DateTime('01:01:01.000001'); $timeH = $time->modify('+1 hour'); echo $timeH->format('H:i:s.u') . '<br>'; // prints 02:01:01.000001 $timeM = $time->modify('+1 minute'); echo $timeM->format('H:i:s.u') . '<br>'; // prints 02:02:01.000001 $timeS = $time->modify('+1 second'); echo $timeS->format('H:i:s.u') . '<br>'; // prints 02:02:02.000001 $timeMS = $time->modify('+1 microsecond'); echo $timeMS->format('H:i:S:u') . '<br>'; // error
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
02:01:01.000001<br>02:02:01.000001<br>02:02:02.000001<br>02:02:th:000002<br>
Output for 7.0.0 - 7.0.20
02:01:01.000001<br>02:02:01.000001<br>02:02:02.000001<br> Warning: DateTime::modify(): Failed to parse time string (+1 microsecond) at position 9 (e): Double timezone specification in /in/otCLg on line 13 Fatal error: Uncaught Error: Call to a member function format() on boolean in /in/otCLg:14 Stack trace: #0 {main} thrown in /in/otCLg on line 14
Process exited with code 255.
Output for 5.6.7 - 5.6.15, 5.6.17 - 5.6.28
02:01:01.000001<br>02:02:01.000001<br>02:02:02.000001<br> Warning: DateTime::modify(): Failed to parse time string (+1 microsecond) at position 9 (e): Double timezone specification in /in/otCLg on line 13 Fatal error: Call to a member function format() on boolean in /in/otCLg on line 14
Process exited with code 255.
Output for 5.6.16
03:01:01.000001<br>03:02:01.000001<br>03:02:02.000001<br> Warning: DateTime::modify(): Failed to parse time string (+1 microsecond) at position 9 (e): Double timezone specification in /in/otCLg on line 13 Fatal error: Call to a member function format() on boolean in /in/otCLg on line 14
Process exited with code 255.
Output for 5.3.7 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35
02:01:01.000001<br>02:02:01.000001<br>02:02:02.000001<br> Warning: DateTime::modify(): Failed to parse time string (+1 microsecond) at position 9 (e): Double timezone specification in /in/otCLg on line 13 Fatal error: Call to a member function format() on a non-object in /in/otCLg on line 14
Process exited with code 255.

preferences:
203.65 ms | 402 KiB | 279 Q