3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $days = []; $searchData = ['dat' => '2015-11-11']; $offset = 3; $now = date_create(); $offsetStart = -1 * $offset; echo date_create($searchData['dat'])->modify($offsetStart .' days')->format('Y-m-d H:i'); echo PHP_EOL . $now->format('Y-m-d H:i:s'); echo PHP_EOL . date_create($now)->diff($searchData['dat'])->days; if (date_create($searchData['dat'])->modify($offsetStart .' days') < $now) { $offsetStart = -1 * date_create($searchData['dat'])->diff($now)->days; } $offsetEnd = 2 * $offset + $offsetStart; for ($i = $offsetStart; $i <= $offsetEnd; $i++) { $days[] = $i; } print_r($days);
based on cvElI
Output for 7.0.0 - 7.1.2, 7.1.4 - 7.2.11
2015-11-08 00:00 2015-11-10 15:54:39 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Uncaught Error: Call to a member function diff() on boolean in /in/rCROY:11 Stack trace: #0 {main} thrown in /in/rCROY on line 11
Process exited with code 255.
Output for hhvm-3.12.14, hhvm-3.15.4, 7.1.3

Process exited with code 137.
Output for hhvm-3.22.0
2015-11-08 00:00 2015-11-10 15:54:40 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line -1 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function diff() on a non-object (null)' in /in/rCROY:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.1 - 3.11.1, hhvm-3.17.3 - 3.19.2, hhvm-3.21.0 - 3.21.3
2015-11-08 00:00 2015-11-10 15:54:40 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function diff() on a non-object (null)' in /in/rCROY:11 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.20.2
2015-11-08 00:00 2015-11-10 15:54:39 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function diff() on a non-object (null)' in /in/rCROY:11 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.13.2
2015-11-08 00:00 2015-11-10 15:54:41 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function diff() on a non-object (null)' in /in/rCROY:11 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.38
2015-11-08 00:00 2015-11-10 15:54:39 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on boolean in /in/rCROY on line 11
Process exited with code 255.
Output for 5.5.0 - 5.5.38
2015-11-08 00:00 2015-11-10 15:54:39 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.45
2015-11-08 00:00 2015-11-10 15:54:41 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.44
2015-11-08 00:00 2015-11-10 15:54:42 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.41 - 5.4.43
2015-11-08 00:00 2015-11-10 15:54:43 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.38 - 5.4.40
2015-11-08 00:00 2015-11-10 15:54:44 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.36 - 5.4.37
2015-11-08 00:00 2015-11-10 15:54:45 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.34 - 5.4.35
2015-11-08 00:00 2015-11-10 15:54:46 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.29 - 5.4.32
2015-11-08 00:00 2015-11-10 15:54:47 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.25 - 5.4.28
2015-11-08 00:00 2015-11-10 15:54:48 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.22 - 5.4.24
2015-11-08 00:00 2015-11-10 15:54:49 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.18 - 5.4.21
2015-11-08 00:00 2015-11-10 15:54:50 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.13 - 5.4.17
2015-11-08 00:00 2015-11-10 15:54:51 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.4.9 - 5.4.12
2015-11-08 00:00 2015-11-10 15:54:52 Warning: date_create() expects parameter 1 to be string, object given in /in/rCROY on line 11 Fatal error: Call to a member function diff() on a non-object in /in/rCROY on line 11
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/rCROY on line 3
Process exited with code 255.