3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // Set demo vars $year = 2012; $months = array(10,11,12); $days = array(01,02,03,04,06,07,08,09,11,12,13,14,16,17,18,19,21,22,23,24,26,27,28,29,31); $dateWs = array(); foreach($months AS $month) foreach($days AS $day) $datesWS[] = new DateTime(implode('-',array($year,$month,$day))); // Push DateTime object to the WebService array // Shuffle shuffle($datesWS); if($datesWS[0] > $datesWS[1]) echo($datesWS[0]->format('d/m/Y').' greater than '.$datesWS[1]->format('d/m/Y')); elseif($datesWS[0] < $datesWS[1]) echo($datesWS[0]->format('d/m/Y').' minor than '.$datesWS[1]->format('d/m/Y')); else echo($datesWS[0]->format('d/m/Y').' is equal than '.$datesWS[1]->format('d/m/Y')); die(); /* // Sort dates usort($datesWS, function ($a, $b){ return ($a == $b) ? 0 : (($a > $b) ? 1 : -1); });*/ $dateIni = count($datesWS)>0 ? reset($datesWS) : 0; // Get first date $dateEnd = count($datesWS)>0 ? end($datesWS) : 0; // Get last date var_dump($dateIni); var_dump($dateEnd); /* $interval = new DateInterval('P1D'); // Set date interval as 1 day // Generate dates range and Transform iterator to array $datesRange = iterator_to_array(new DatePeriod($dateIni, $interval, $dateEnd->modify( '+1 day' ))); // This way seems to work foreach($datesRange AS $date) { if(!in_array($date->format('d/m/Y'),array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$datesWS)))) $excludeDates[] = $date->format('d/m/Y'); } // This way should be more efficient, but I'm fed up with it! // Get excluded dates $excludeDates = array_udiff($datesRange, $datesWS, function ($a, $b) { return $a == $b ? 0 : 1; }); // Comment/Uncomment this in order to print this method or the other one // Print array(objects) as array(strings) var_dump(array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$datesWS))); var_dump(array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$datesRange))); var_dump(array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$excludeDates))); */ ?>
Output for hhvm-3.12.0
16/11/2012 greater than 07/10/2012
Output for hhvm-3.10.0
14/11/2012 minor than 22/12/2012
Output for 5.6.28
29/11/2012 minor than 18/12/2012
Output for 5.6.25
11/12/2012 greater than 24/11/2012
Output for 5.6.24
29/11/2012 greater than 12/11/2012
Output for 5.6.23
02/12/2012 greater than 02/10/2012
Output for 5.6.22
23/10/2012 minor than 27/12/2012
Output for 5.6.21
18/11/2012 minor than 01/12/2012
Output for 5.6.20
16/10/2012 minor than 13/11/2012
Output for 5.6.19
02/10/2012 minor than 06/11/2012
Output for 5.6.18
26/11/2012 greater than 14/10/2012
Output for 5.6.17
29/11/2012 greater than 14/10/2012
Output for 5.6.16
31/12/2012 greater than 30/11/2012
Output for 5.6.15
03/11/2012 minor than 18/12/2012
Output for 5.6.14
28/12/2012 greater than 12/10/2012
Output for 5.6.13
01/12/2012 greater than 04/10/2012
Output for 5.6.12
11/12/2012 greater than 30/11/2012
Output for 5.6.11
01/10/2012 minor than 19/12/2012
Output for 5.6.10
17/11/2012 greater than 18/10/2012
Output for 5.6.9
24/12/2012 greater than 14/11/2012
Output for 5.6.8
13/10/2012 minor than 30/11/2012
Output for 5.6.7
02/11/2012 minor than 01/12/2012
Output for 5.6.6
06/11/2012 minor than 13/12/2012
Output for 5.6.5
23/11/2012 minor than 29/11/2012
Output for 5.6.4
21/11/2012 minor than 17/12/2012
Output for 5.6.3
07/10/2012 minor than 03/12/2012
Output for 5.6.2
18/10/2012 minor than 27/11/2012
Output for 5.6.1
07/11/2012 minor than 07/12/2012
Output for 5.6.0
03/12/2012 greater than 22/11/2012
Output for 5.5.38
06/10/2012 minor than 01/12/2012
Output for 5.5.37
28/10/2012 greater than 02/10/2012
Output for 5.5.36
30/11/2012 minor than 01/12/2012
Output for 5.5.35
27/12/2012 greater than 06/12/2012
Output for 5.5.34
04/11/2012 minor than 26/12/2012
Output for 5.5.33
29/11/2012 greater than 21/10/2012
Output for 5.5.32
22/12/2012 minor than 31/12/2012
Output for 5.5.31
29/11/2012 minor than 11/12/2012
Output for 5.5.30
29/10/2012 minor than 18/12/2012
Output for 5.5.29
02/11/2012 minor than 27/11/2012
Output for 5.5.28
24/11/2012 minor than 04/12/2012
Output for 5.5.27
12/11/2012 minor than 29/11/2012
Output for 5.5.26
14/11/2012 minor than 27/12/2012
Output for 5.5.25
02/11/2012 minor than 12/12/2012
Output for 5.5.24
22/10/2012 minor than 24/11/2012
Output for 5.5.23
19/11/2012 greater than 21/10/2012
Output for 5.5.22
18/12/2012 greater than 14/11/2012
Output for 5.5.21
14/10/2012 minor than 01/11/2012
Output for 5.5.20
11/12/2012 greater than 18/11/2012
Output for 5.5.19
21/12/2012 greater than 14/11/2012
Output for 5.5.18
31/10/2012 minor than 23/12/2012
Output for 5.5.16
19/10/2012 minor than 11/11/2012
Output for 5.5.15
19/10/2012 minor than 13/12/2012
Output for 5.5.14
23/12/2012 greater than 13/11/2012
Output for 5.5.13
03/12/2012 greater than 12/11/2012
Output for 5.5.12
01/12/2012 greater than 12/11/2012
Output for 5.5.11
28/12/2012 greater than 14/10/2012
Output for 5.5.10
18/12/2012 minor than 24/12/2012
Output for 5.5.9
07/10/2012 minor than 22/11/2012
Output for 5.5.8
29/12/2012 greater than 18/10/2012
Output for 5.5.7
07/11/2012 minor than 24/11/2012
Output for 5.5.6
02/10/2012 minor than 19/11/2012
Output for 5.5.5
01/12/2012 greater than 23/11/2012
Output for 5.5.4
06/10/2012 minor than 11/12/2012
Output for 5.5.3
22/11/2012 minor than 23/12/2012
Output for 5.5.2
17/11/2012 greater than 14/10/2012
Output for 5.5.1
07/11/2012 minor than 17/12/2012
Output for 5.5.0
19/12/2012 minor than 26/12/2012
Output for 5.4.45
19/11/2012 minor than 24/11/2012
Output for 5.4.44
03/10/2012 minor than 06/12/2012
Output for 5.4.43
03/10/2012 minor than 01/12/2012
Output for 5.4.42
01/12/2012 greater than 18/10/2012
Output for 5.4.41
02/12/2012 greater than 23/11/2012
Output for 5.4.40
31/12/2012 greater than 14/12/2012
Output for 5.4.39
17/12/2012 greater than 19/11/2012
Output for 5.4.38
29/10/2012 greater than 16/10/2012
Output for 5.4.37
21/11/2012 minor than 30/11/2012
Output for 5.4.36
30/09/2012 minor than 06/12/2012
Output for 5.4.35
30/11/2012 minor than 18/12/2012
Output for 5.4.34
24/11/2012 minor than 28/12/2012
Output for 5.4.32
07/11/2012 greater than 03/10/2012
Output for 5.4.31
02/11/2012 greater than 28/10/2012
Output for 5.4.30
24/10/2012 greater than 06/10/2012
Output for 5.4.29
26/12/2012 greater than 01/12/2012
Output for 5.4.28
06/12/2012 greater than 13/10/2012
Output for 5.4.27
07/10/2012 minor than 01/12/2012
Output for 5.4.26
06/11/2012 greater than 24/10/2012
Output for 5.4.25
14/11/2012 minor than 26/12/2012
Output for 5.4.24
14/12/2012 greater than 12/11/2012
Output for 5.4.23
12/12/2012 greater than 30/09/2012
Output for 5.4.22
12/11/2012 minor than 29/12/2012
Output for 5.4.21
24/10/2012 minor than 02/11/2012
Output for 5.4.20
19/12/2012 greater than 30/11/2012
Output for 5.4.19
28/10/2012 greater than 23/10/2012
Output for 5.4.18
17/10/2012 minor than 24/11/2012
Output for 5.4.17
17/12/2012 minor than 31/12/2012
Output for 5.4.16
23/11/2012 greater than 28/10/2012
Output for 5.4.15
29/11/2012 greater than 11/10/2012
Output for 5.4.14
04/10/2012 minor than 01/12/2012
Output for 5.4.13
27/11/2012 minor than 29/12/2012
Output for 5.4.12
13/12/2012 greater than 07/12/2012
Output for 5.4.11
27/12/2012 greater than 21/12/2012
Output for 5.4.10
01/11/2012 minor than 06/11/2012
Output for 5.4.9
01/11/2012 minor than 24/12/2012
Output for 5.4.8
24/11/2012 greater than 14/11/2012
Output for 5.4.7
17/12/2012 minor than 18/12/2012
Output for 5.4.6
18/11/2012 minor than 31/12/2012
Output for 5.4.5
06/12/2012 greater than 19/10/2012
Output for 5.4.4
21/12/2012 greater than 12/12/2012
Output for 5.4.3
18/10/2012 minor than 29/10/2012
Output for 5.4.2
28/10/2012 minor than 19/12/2012
Output for 5.4.1
23/11/2012 greater than 17/11/2012
Output for 5.4.0
26/10/2012 minor than 12/11/2012
Output for 5.3.29
29/12/2012 greater than 16/12/2012
Output for 5.3.28
13/10/2012 minor than 21/12/2012
Output for 5.3.27
18/12/2012 greater than 06/10/2012
Output for 5.3.26
27/10/2012 greater than 11/10/2012
Output for 5.3.25
23/10/2012 minor than 31/10/2012
Output for 5.3.24
13/12/2012 greater than 12/12/2012
Output for 5.3.23
13/11/2012 greater than 27/10/2012
Output for 5.3.22
14/12/2012 greater than 31/10/2012
Output for 5.3.21
02/12/2012 greater than 14/11/2012
Output for 5.3.20
31/10/2012 minor than 30/11/2012
Output for 5.3.19
22/12/2012 minor than 23/12/2012
Output for 5.3.18
06/12/2012 greater than 18/11/2012
Output for 5.3.17
07/12/2012 greater than 21/11/2012
Output for 5.3.16
01/12/2012 greater than 26/11/2012
Output for 5.3.15
23/10/2012 greater than 01/10/2012
Output for 5.3.14
16/11/2012 minor than 26/11/2012
Output for 5.3.13
30/09/2012 minor than 31/10/2012
Output for 5.3.12
23/10/2012 minor than 17/11/2012
Output for 5.3.11
18/10/2012 minor than 01/11/2012
Output for 5.3.10
24/10/2012 minor than 14/12/2012
Output for 5.3.9
12/12/2012 greater than 01/10/2012
Output for 5.3.8
04/10/2012 minor than 28/11/2012
Output for 5.3.7
14/12/2012 greater than 06/11/2012
Output for 5.3.6
23/11/2012 greater than 12/10/2012
Output for 5.3.5
14/10/2012 minor than 27/11/2012
Output for 5.3.4
07/10/2012 minor than 11/12/2012
Output for 5.3.3
29/12/2012 greater than 26/12/2012
Output for 5.3.2
12/11/2012 greater than 26/10/2012
Output for 5.3.1
19/10/2012 minor than 04/12/2012
Output for 5.3.0
31/10/2012 minor than 01/11/2012
Output for 5.2.17
24/11/2012 greater than 27/10/2012
Output for 5.2.16
11/11/2012 greater than 26/10/2012
Output for 5.2.15
11/10/2012 minor than 29/11/2012
Output for 5.2.14
07/12/2012 greater than 07/10/2012
Output for 5.2.13
17/11/2012 greater than 07/10/2012
Output for 5.2.12
23/12/2012 greater than 31/10/2012
Output for 5.2.11
01/12/2012 is equal than 01/12/2012
Output for 5.2.10
31/10/2012 greater than 14/10/2012
Output for 5.2.9
06/11/2012 minor than 03/12/2012
Output for 5.2.8
16/10/2012 minor than 04/12/2012
Output for 5.2.7
21/10/2012 minor than 12/12/2012
Output for 5.2.6
13/11/2012 greater than 23/10/2012
Output for 5.2.5
19/11/2012 greater than 07/11/2012
Output for 5.2.4
02/11/2012 greater than 23/10/2012
Output for 5.2.3
21/11/2012 greater than 13/10/2012
Output for 5.2.2
21/12/2012 greater than 07/12/2012
Output for 5.2.1
18/12/2012 is equal than 31/12/2012
Output for 5.2.0
28/10/2012 is equal than 02/11/2012
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/q9v1b on line 11
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/q9v1b on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/q9v1b on line 11