3v4l.org

run code in 300+ PHP versions simultaneously
<?php function countDaysByName($dayName, \DateTime $start, \DateTime $end) { $count = 0; $interval = new \DateInterval('P1D'); $period = new \DatePeriod($start, $interval, $end); foreach($period as $day){ if($day->format('D') === ucfirst(substr($dayName, 0, 3))){ $count ++; } } return $count; } echo countDaysByName('wednesday', new \DateTime(2016-01-18), new \DateTime(2016-01-23)); echo date('c', new \DateTime(2016-01-18));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
0 Fatal error: Uncaught TypeError: date(): Argument #2 ($timestamp) must be of type ?int, DateTime given in /in/pHgp2:19 Stack trace: #0 /in/pHgp2(19): date('c', Object(DateTime)) #1 {main} thrown in /in/pHgp2 on line 19
Process exited with code 255.
Output for 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
0 Warning: date() expects parameter 2 to be int, object given in /in/pHgp2 on line 19
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33
0 Warning: date() expects parameter 2 to be integer, object given in /in/pHgp2 on line 19
Output for 5.5.0 - 5.5.37, 5.6.0 - 5.6.23
0 Warning: date() expects parameter 2 to be long, object given in /in/pHgp2 on line 19

preferences:
192.57 ms | 401 KiB | 213 Q