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.20 - 7.2.0
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 7.0.6
2015-11-08 00:00 2016-05-03 18:37:06 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 7.0.5
2015-11-08 00:00 2016-04-03 07:01:54 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 7.0.4
2015-11-08 00:00 2016-03-10 18:49:10 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 7.0.3
2015-11-08 00:00 2016-03-18 19:58:36 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 7.0.2
2015-11-08 00:00 2016-03-23 02:06:52 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 7.0.1
2015-11-08 00:00 2016-03-24 05:44:28 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 7.0.0
2015-11-08 00:00 2016-03-27 07:40:27 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 5.6.28
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.6.21
2015-11-08 00:00 2016-05-02 13:46:11 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.6.20
2015-11-08 00:00 2016-04-10 06:01:08 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.6.19
2015-11-08 00:00 2016-03-08 03:00: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 boolean in /in/rCROY on line 11
Process exited with code 255.
Output for 5.6.18
2015-11-08 00:00 2016-03-15 11:44: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 boolean in /in/rCROY on line 11
Process exited with code 255.
Output for 5.6.17
2015-11-08 00:00 2016-03-19 23:23: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 boolean in /in/rCROY on line 11
Process exited with code 255.
Output for 5.6.16
2015-11-08 00:00 2016-03-28 08:27:38 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.6.15
2015-11-08 00:00 2016-03-29 09:18:18 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.6.14
2015-11-08 00:00 2016-04-02 11:09:13 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.6.13
2015-11-08 00:00 2016-04-15 15:34:00 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.6.12
2015-11-08 00:00 2016-04-20 06:03:33 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.6.11
2015-11-08 00:00 2016-04-24 12:26:35 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.6.10
2015-11-08 00:00 2016-04-25 14:28: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 boolean in /in/rCROY on line 11
Process exited with code 255.
Output for 5.6.9
2015-11-08 00:00 2016-04-27 19:38:40 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.6.8
2015-11-08 00:00 2016-04-30 04:30: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 boolean in /in/rCROY on line 11
Process exited with code 255.
Output for 5.5.35
2015-11-08 00:00 2016-05-22 21:14:28 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.5.34
2015-11-08 00:00 2016-04-11 08:13:04 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.5.33
2015-11-08 00:00 2016-03-09 05:45:27 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.5.32
2015-11-08 00:00 2016-03-17 15:40:30 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.5.31
2015-11-08 00:00 2016-03-21 02:26:08 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.5.30
2015-11-08 00:00 2016-04-01 11:12:13 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.5.29
2015-11-08 00:00 2016-04-17 05:57:12 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.5.28
2015-11-08 00:00 2016-04-21 09:17:30 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.5.27
2015-11-08 00:00 2016-04-22 11:03: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.5.26
2015-11-08 00:00 2016-04-26 17:11: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.5.25
2015-11-08 00:00 2016-04-29 00:07:25 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.5.24
2015-11-08 00:00 2016-05-24 06:36:18 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.