3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //$userTimezone = new \DateTimeZone('Europe/Helsinki'); $from = new \DateTime( 'now' ); $from->modify( 'first day of this month' ); //$from->sub( new \DateInterval( 'P5D' ) ); var_dump($from);
based on ofAJS
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-10-01 12:12:47.003968" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.28, 7.0.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-10-01 12:12:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-01 10:18:38.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 23:05:39.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 09:41:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 10:21:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 16:19:31.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 20:55:31.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 22:27:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.21
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-01 05:38:24.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 22:05:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.19
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 17:48:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.18
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 01:54:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.17
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 14:34:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 00:15:39.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 01:20:16.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 03:39:32.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 07:33:43.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 21:21:45.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 04:23:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 06:08:38.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 11:07:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 19:15:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.35
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-01 09:26:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 00:24:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.33
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 20:45:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 03:28:35.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-01 17:20:15.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 03:17:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.29
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 21:40:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.28
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 00:37:06.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.27
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 02:55:09.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.26
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 08:34:56.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.25
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 14:53:31.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.24
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-01 22:14:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.45
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-09-01 10:30:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.44
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-01 03:38:06.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.43
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-01 03:38:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.42
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-01 03:38:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.41
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-01 03:37:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.39 - 5.4.40
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-08-01 03:37:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.38
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-01 15:23:02.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.37
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-01 15:22:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.35 - 5.4.36
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-01 15:22:54.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-01 15:22:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.30 - 5.4.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-10-01 12:12:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.22 - 5.4.29
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-10-01 12:12:51" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.0 - 5.4.21
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-10-01 12:12:52" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.8 - 5.3.29
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-10-01 12:12:53" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.0 - 5.3.7
object(DateTime)#1 (3) { ["date"]=> string(19) "2014-10-01 12:12:54" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.2.13 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vb3g8 on line 4 Warning: DateTime::modify(): 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/vb3g8 on line 5 object(DateTime)#1 (0) { }
Output for 5.2.0 - 5.2.12
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vb3g8 on line 4 object(DateTime)#1 (0) { }
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vb3g8 on line 4 Fatal error: Class 'DateTime' not found in /in/vb3g8 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vb3g8 on line 4 Fatal error: Cannot instantiate non-existent class: datetime in /in/vb3g8 on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vb3g8 on line 4 Fatal error: Cannot instantiate non-existent class: datetime in /in/vb3g8 on line 4