3v4l.org

run code in 300+ PHP versions simultaneously
<?php $time = new DateTime(); $time2 = new DateTime('-2hours'); echo $time2->format('c').PHP_EOL; $sub = new DateInterval('PT1H'); $time->sub($sub); echo $time->format('c');
Output for 5.3.0, 5.3.2, 5.3.4, 5.3.13, 5.3.22, 5.3.24 - 5.3.27, 5.4.2, 5.4.6, 5.4.9, 5.4.15 - 5.4.24, 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
2014-02-09T19:07:05+01:00 2014-02-09T20:07:05+01:00
Output for 7.3.32 - 7.3.33, 8.0.13
2014-02-09T18:07:05+00:00 2014-02-09T19:07:05+00:00
Output for 7.0.6
2016-05-02T23:58:59+02:00 2016-05-03T00:58:59+02:00
Output for 7.0.5
2016-04-02T13:16:17+02:00 2016-04-02T14:16:17+02:00
Output for 7.0.4
2016-03-09T22:42:40+01:00 2016-03-09T23:42:40+01:00
Output for 7.0.3
2016-03-17T22:55:04+01:00 2016-03-17T23:55:04+01:00
Output for 7.0.2
2016-03-21T09:30:32+01:00 2016-03-21T10:30:32+01:00
Output for 7.0.1
2016-03-23T09:41:58+01:00 2016-03-23T10:41:58+01:00
Output for 7.0.0
2016-03-26T12:14:23+01:00 2016-03-26T13:14:23+01:00
Output for 5.6.21
2016-05-01T19:02:52+02:00 2016-05-01T20:02:52+02:00
Output for 5.6.20
2016-04-09T08:31:15+02:00 2016-04-09T09:31:15+02:00
Output for 5.6.19
2016-03-06T20:52:25+01:00 2016-03-06T21:52:25+01:00
Output for 5.6.18
2016-03-14T08:21:05+01:00 2016-03-14T09:21:05+01:00
Output for 5.6.17
2016-03-19T03:24:15+01:00 2016-03-19T04:24:15+01:00
Output for 5.6.16
2016-03-27T13:58:05+02:00 2016-03-27T14:58:05+02:00
Output for 5.6.15
2016-03-28T14:52:23+02:00 2016-03-28T15:52:23+02:00
Output for 5.6.14
2016-04-01T17:32:02+02:00 2016-04-01T18:32:02+02:00
Output for 5.6.13
2016-04-14T21:19:46+02:00 2016-04-14T22:19:46+02:00
Output for 5.6.12
2016-04-19T10:27:34+02:00 2016-04-19T11:27:34+02:00
Output for 5.6.11
2016-04-22T17:43:48+02:00 2016-04-22T18:43:48+02:00
Output for 5.6.10
2016-04-24T19:23:43+02:00 2016-04-24T20:23:43+02:00
Output for 5.6.9
2016-04-27T00:32:23+02:00 2016-04-27T01:32:23+02:00
Output for 5.6.8
2016-04-29T08:07:15+02:00 2016-04-29T09:07:15+02:00
Output for 5.5.35
2016-05-21T22:19:39+02:00 2016-05-21T23:19:39+02:00
Output for 5.5.34
2016-04-10T14:26:33+02:00 2016-04-10T15:26:33+02:00
Output for 5.5.33
2016-03-08T09:37:25+01:00 2016-03-08T10:37:25+01:00
Output for 5.5.32
2016-03-16T15:17:16+01:00 2016-03-16T16:17:16+01:00
Output for 5.5.31
2016-03-20T06:17:25+01:00 2016-03-20T07:17:25+01:00
Output for 5.5.30
2016-03-31T16:54:32+02:00 2016-03-31T17:54:32+02:00
Output for 5.5.29
2016-04-16T11:25:56+02:00 2016-04-16T12:25:56+02:00
Output for 5.5.28
2016-04-20T13:41:16+02:00 2016-04-20T14:41:16+02:00
Output for 5.5.27
2016-04-21T16:15:43+02:00 2016-04-21T17:15:43+02:00
Output for 5.5.26
2016-04-25T21:40:55+02:00 2016-04-25T22:40:55+02:00
Output for 5.5.25
2016-04-28T03:48:39+02:00 2016-04-28T04:48:39+02:00
Output for 5.5.24
2016-04-30T11:21:14+02:00 2016-04-30T12:21:14+02:00
Output for 5.4.45
2015-09-13T17:51:18+02:00 2015-09-13T18:51:18+02:00
Output for 5.4.44
2015-08-15T18:46:01+02:00 2015-08-15T19:46:01+02:00
Output for 5.4.43
2015-08-15T18:45:57+02:00 2015-08-15T19:45:57+02:00
Output for 5.4.42
2015-08-15T18:45:56+02:00 2015-08-15T19:45:56+02:00
Output for 5.4.41
2015-08-15T18:45:53+02:00 2015-08-15T19:45:53+02:00
Output for 5.4.40
2015-05-08T04:59:08+02:00 2015-05-08T05:59:08+02:00
Output for 5.4.39
2015-05-08T04:59:07+02:00 2015-05-08T05:59:07+02:00
Output for 5.4.38
2015-03-02T05:32:39+01:00 2015-03-02T06:32:39+01:00
Output for 5.4.37
2015-02-07T23:57:38+01:00 2015-02-08T00:57:38+01:00
Output for 5.4.36
2015-02-07T23:57:37+01:00 2015-02-08T00:57:37+01:00
Output for 5.4.35
2014-12-04T15:10:38+01:00 2014-12-04T16:10:38+01:00
Output for 5.4.34
2014-12-04T15:10:37+01:00 2014-12-04T16:10:37+01:00
Output for 5.4.32
2014-09-06T03:38:09+02:00 2014-09-06T04:38:09+02:00
Output for 5.4.31
2014-09-06T03:38:04+02:00 2014-09-06T04:38:04+02:00
Output for 5.3.29, 5.4.30
2014-09-06T03:38:00+02:00 2014-09-06T04:38:00+02:00
Output for 5.4.28 - 5.4.29
2014-09-06T03:37:59+02:00 2014-09-06T04:37:59+02:00
Output for 5.4.26 - 5.4.27
2014-09-06T03:38:06+02:00 2014-09-06T04:38:06+02:00
Output for 5.4.25
2014-09-06T03:38:05+02:00 2014-09-06T04:38:05+02:00
Output for 5.3.1, 5.3.3, 5.3.5 - 5.3.12, 5.3.14 - 5.3.21, 5.3.23, 5.3.28, 5.4.0 - 5.4.1, 5.4.3 - 5.4.5, 5.4.7 - 5.4.8, 5.4.10 - 5.4.14
2014-02-09T19:07:04+01:00 2014-02-09T20:07:04+01:00
Output for 5.2.0 - 5.2.17
2014-02-09T19:07:04+01:00 Fatal error: Class 'DateInterval' not found in /in/pTY87 on line 5
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/pTY87 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/pTY87 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/pTY87 on line 2

preferences:
229.6 ms | 401 KiB | 343 Q