3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dt = new DateTime("first day of this month"); echo $dt->format("Y-m-d H:i\n"); $dt->sub(new DateInterval("P1D")); echo $dt->format("Y-m-d H:i\n");
Output for 7.0.12 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
2013-04-01 09:25 2013-03-31 09:25
Output for 7.3.32 - 7.3.33, 7.4.26, 8.0.13
2013-04-01 07:25 2013-03-31 07:25
Output for 7.0.6
2016-05-01 00:52 2016-04-30 00:52
Output for 7.0.5
2016-04-01 14:14 2016-03-31 14:14
Output for 7.0.4
2016-03-01 23:13 2016-02-29 23:13
Output for 7.0.3
2016-03-01 23:38 2016-02-29 23:38
Output for 7.0.2
2016-03-01 10:20 2016-02-29 10:20
Output for 7.0.1
2016-03-01 10:00 2016-02-29 10:00
Output for 7.0.0
2016-03-01 13:03 2016-02-29 13:03
Output for 5.6.21
2016-05-01 19:57 2016-04-30 19:57
Output for 5.6.20
2016-04-01 09:29 2016-03-31 09:29
Output for 5.6.19
2016-03-01 20:41 2016-02-29 20:41
Output for 5.6.18
2016-03-01 09:09 2016-02-29 09:09
Output for 5.6.17
2016-03-01 04:14 2016-02-29 04:14
Output for 5.6.16
2016-03-01 14:48 2016-02-29 14:48
Output for 5.6.15
2016-03-01 15:47 2016-02-29 15:47
Output for 5.6.14
2016-04-01 18:28 2016-03-31 18:28
Output for 5.6.13
2016-04-01 22:24 2016-03-31 22:24
Output for 5.6.12
2016-04-01 11:28 2016-03-31 11:28
Output for 5.6.11
2016-04-01 18:46 2016-03-31 18:46
Output for 5.6.10
2016-04-01 20:25 2016-03-31 20:25
Output for 5.6.9
2016-04-01 01:30 2016-03-31 01:30
Output for 5.6.8
2016-04-01 09:04 2016-03-31 09:04
Output for 5.6.7
2016-05-01 18:57 2016-04-30 18:57
Output for 5.5.35
2016-05-01 23:01 2016-04-30 23:01
Output for 5.5.34
2016-04-01 15:19 2016-03-31 15:19
Output for 5.5.33
2016-03-01 10:27 2016-02-29 10:27
Output for 5.5.32
2016-03-01 19:27 2016-02-29 19:27
Output for 5.5.31
2016-03-01 07:08 2016-02-29 07:08
Output for 5.5.30
2016-03-01 17:51 2016-02-29 17:51
Output for 5.5.29
2016-04-01 12:27 2016-03-31 12:27
Output for 5.5.28
2016-04-01 14:39 2016-03-31 14:39
Output for 5.5.27
2016-04-01 17:17 2016-03-31 17:17
Output for 5.5.26
2016-04-01 22:40 2016-03-31 22:40
Output for 5.5.25
2016-04-01 04:46 2016-03-31 04:46
Output for 5.5.24
2016-04-01 12:25 2016-03-31 12:25
Output for 5.3.7 - 5.3.29, 5.4.0 - 5.4.45
2016-02-01 22:35 2016-01-31 22:35
Output for 5.3.0 - 5.3.6
2016-02-01 22:35 2016-02-01 22:35
Output for 5.2.0 - 5.2.17
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (first day of this month) at position 10 (o): The timezone could not be found in the database' in /in/B19n2:2 Stack trace: #0 /in/B19n2(2): DateTime->__construct('first day of th...') #1 {main} thrown in /in/B19n2 on line 2
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/B19n2 on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/B19n2 on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/B19n2 on line 2

preferences:
210.15 ms | 401 KiB | 314 Q