3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = "blah 2015 yar"; $pos = strpos($string, "20"); $year = substr($string, $pos, 4); $end_year = "12/31/" . $year; $end_time = new DateTime($end_year); print_r($end_time); $start_time = new DateTime(); print_r($start_time); $date1 = $end_time->format('Y-m-d'); $date2 = $start_time->format('Y-m-d'); $diff = $date2->diff($date1); print_r($diff); ?>
based on N1npg
Output for 7.1.0
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2014-10-02 22:49:14.004047 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Uncaught Error: Call to a member function diff() on string in /in/AtDZV:15 Stack trace: #0 {main} thrown in /in/AtDZV on line 15
Process exited with code 255.
Output for 7.0.14
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2014-10-02 22:49:14.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Uncaught Error: Call to a member function diff() on string in /in/AtDZV:15 Stack trace: #0 {main} thrown in /in/AtDZV on line 15
Process exited with code 255.
Output for 7.0.6
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-05-03 10:16:22.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Uncaught Error: Call to a member function diff() on string in /in/AtDZV:15 Stack trace: #0 {main} thrown in /in/AtDZV on line 15
Process exited with code 255.
Output for 7.0.5
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-02 23:03:38.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Uncaught Error: Call to a member function diff() on string in /in/AtDZV:15 Stack trace: #0 {main} thrown in /in/AtDZV on line 15
Process exited with code 255.
Output for 7.0.4
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-10 09:39:05.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Uncaught Error: Call to a member function diff() on string in /in/AtDZV:15 Stack trace: #0 {main} thrown in /in/AtDZV on line 15
Process exited with code 255.
Output for 7.0.3
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-18 10:18:39.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Uncaught Error: Call to a member function diff() on string in /in/AtDZV:15 Stack trace: #0 {main} thrown in /in/AtDZV on line 15
Process exited with code 255.
Output for 7.0.2
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-22 16:17:08.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Uncaught Error: Call to a member function diff() on string in /in/AtDZV:15 Stack trace: #0 {main} thrown in /in/AtDZV on line 15
Process exited with code 255.
Output for 7.0.1
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-23 20:53:22.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Uncaught Error: Call to a member function diff() on string in /in/AtDZV:15 Stack trace: #0 {main} thrown in /in/AtDZV on line 15
Process exited with code 255.
Output for 7.0.0
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-26 22:25:51.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Uncaught Error: Call to a member function diff() on string in /in/AtDZV:15 Stack trace: #0 {main} thrown in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.28
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2014-10-02 22:49:14.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.21
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-05-02 05:36:13.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.20
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-09 22:02:42.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.19
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-07 17:46:48.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.18
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-15 01:51:53.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.17
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-19 14:32:36.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.16
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-28 00:13:28.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.15
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-29 01:18:07.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.14
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-02 03:37:25.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.13
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-15 07:31:38.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.12
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-19 21:19:24.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.11
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-23 04:21:39.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.10
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-25 06:06:22.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.9
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-27 11:05:19.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.6.8
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-29 19:13:17.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on string in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.35
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-05-22 09:23:49.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.34
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-11 00:22:29.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.33
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-08 20:43:54.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.32
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-17 03:26:13.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.31
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-03-20 17:18:05.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.30
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-01 03:14:50.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.29
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-16 21:38:38.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.28
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-21 00:34:32.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.27
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-22 02:52:54.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.26
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-26 08:32:40.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.25
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-04-28 14:51:08.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.5.24
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2016-05-23 22:11:56.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.45
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2015-09-20 09:52:03.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.44
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2015-09-20 09:52:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.43
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2015-09-20 09:51:56.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.42
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2015-09-20 09:51:55.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.41
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2015-09-20 09:51:53.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.40
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2015-09-20 09:51:52.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.39
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2015-09-20 09:51:50.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.38
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2015-03-15 12:57:10.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.36 - 5.4.37
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2015-03-15 12:57:03.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.34 - 5.4.35
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2015-03-15 12:57:02.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.30 - 5.4.32
DateTime Object ( [date] => 2015-12-31 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2014-10-02 22:49:19.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.4.13 - 5.4.29
DateTime Object ( [date] => 2015-12-31 00:00:00 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2014-10-02 22:49:19 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.3.22 - 5.4.12
DateTime Object ( [date] => 2015-12-31 00:00:00 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2014-10-02 22:49:20 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.3.0 - 5.3.21
DateTime Object ( [date] => 2015-12-31 00:00:00 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2014-10-02 22:49:21 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.2.0 - 5.2.17
DateTime Object ( ) DateTime Object ( ) Fatal error: Call to a member function diff() on a non-object in /in/AtDZV on line 15
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/AtDZV on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/AtDZV on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/AtDZV on line 7