3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = new DateTime('first day of next month'); $b = new DateTime('2015-1-31 00:00'); //$a->add(new DateInterval('P6Y')); //echo $a->format('Y-m-d H:i:s'); //echo date('Y-m-d', strtotime('+1 month', strtotime('2015-1-31'))); //echo $a < $b ? 'ja' : 'nein'; //echo date('Y-m-d','2015-1-31' + strtotime('+3 months')); //$a->modify('last day of +2 month'); echo $a->format('Y-m-d H:i:s');
Output for 5.6.28, 7.0.14 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 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
2015-05-01 16:10:32
Output for 7.3.32 - 7.3.33, 8.0.13
2015-05-01 14:10:32
Output for 7.0.6
2016-06-01 15:58:02
Output for 7.0.5
2016-05-01 04:32:39
Output for 7.0.4
2016-04-01 16:02:42
Output for 7.0.3
2016-04-01 16:44:18
Output for 7.0.2
2016-04-01 22:50:51
Output for 7.0.1
2016-04-01 03:07:17
Output for 7.0.0
2016-04-01 05:05:15
Output for 5.6.21
2016-06-01 11:10:02
Output for 5.6.20
2016-05-01 03:29:43
Output for 5.6.19
2016-04-01 23:44:44
Output for 5.6.18
2016-04-01 08:40:35
Output for 5.6.17
2016-04-01 20:35:02
Output for 5.6.16
2016-04-01 05:53:41
Output for 5.6.15
2016-04-01 06:45:19
Output for 5.6.14
2016-05-01 08:44:41
Output for 5.6.13
2016-05-01 12:58:41
Output for 5.6.12
2016-05-01 03:22:05
Output for 5.6.11
2016-05-01 09:54:25
Output for 5.6.10
2016-05-01 11:48:24
Output for 5.6.9
2016-05-01 16:55:31
Output for 5.6.8
2016-05-01 01:36:40
Output for 5.5.35
2016-06-01 16:04:04
Output for 5.5.34
2016-05-01 05:44:10
Output for 5.5.33
2016-04-01 02:50:34
Output for 5.5.32
2016-04-01 12:22:24
Output for 5.5.31
2016-04-01 23:20:44
Output for 5.5.30
2016-05-01 08:38:39
Output for 5.5.29
2016-05-01 03:20:28
Output for 5.5.28
2016-05-01 06:32:39
Output for 5.5.27
2016-05-01 08:31:34
Output for 5.5.26
2016-05-01 14:28:41
Output for 5.5.25
2016-05-01 21:15:01
Output for 5.5.24
2016-06-01 04:03:55
Output for 5.4.45
2015-10-01 06:27:03
Output for 5.4.44
2015-09-01 07:09:40
Output for 5.4.43
2015-09-01 07:09:35
Output for 5.4.42
2015-09-01 07:09:34
Output for 5.4.41
2015-09-01 07:09:32
Output for 5.4.40
2015-09-01 07:09:27
Output for 5.4.32 - 5.4.39
2015-05-01 16:10:38
Output for 5.4.19 - 5.4.31
2015-05-01 16:10:39
Output for 5.4.8 - 5.4.18
2015-05-01 16:10:40
Output for 5.3.26 - 5.3.29, 5.4.0 - 5.4.7
2015-05-01 16:10:41
Output for 5.3.14 - 5.3.25
2015-05-01 16:10:42
Output for 5.3.0 - 5.3.13
2015-05-01 16:10:43
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 next month) at position 10 (o): The timezone could not be found in the database' in /in/6lMir:3 Stack trace: #0 /in/6lMir(3): DateTime->__construct('first day of ne...') #1 {main} thrown in /in/6lMir on line 3
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/6lMir on line 3
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/6lMir on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/6lMir on line 3

preferences:
229.55 ms | 401 KiB | 341 Q