3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getDaysInWeek ($weekNumber, $year) { // Count from '0104' because January 4th is always in week 1 // (according to ISO 8601). $time = strtotime($year . '0104 +' . ($weekNumber - 1) . ' weeks'); // Get the time of the first day of the week $mondayTime = strtotime('-' . (date('w', $time) + 1) . ' days', $time); // Get the times of days 0 -> 6 $dayTimes = array (); for ($i = 0; $i < 5; ++$i) { $dayTimes[] = strtotime('+' . $i . ' days', $mondayTime); } // Return timestamps for mon-sun. return $dayTimes; } echo "working days in the 53th week from 2015". "<br>"; setlocale(LC_ALL, 'nl_NL'); $werkdagen = getDaysInWeek("53", "2015"); echo (strftime('%d-%m-%Y', $werkdagen[0])) . "<br>"; echo (strftime('%d-%m-%Y', $werkdagen[1])) . "<br>"; echo (strftime('%d-%m-%Y', $werkdagen[2])) . "<br>"; echo (strftime('%d-%m-%Y', $werkdagen[3])) . "<br>"; echo (strftime('%d-%m-%Y', $werkdagen[4])) . "<br>"; echo "<br>"; echo "working days in the 1st week from 2016". "<br>"; $werkdagen = getDaysInWeek("1", "2016"); echo (strftime('%d-%m-%Y', $werkdagen[0])) . "<br>"; echo (strftime('%d-%m-%Y', $werkdagen[1])) . "<br>"; echo (strftime('%d-%m-%Y', $werkdagen[2])) . "<br>"; echo (strftime('%d-%m-%Y', $werkdagen[3])) . "<br>"; echo (strftime('%d-%m-%Y', $werkdagen[4])) . "<br>"; echo "<br>"; ?>
Output for 5.1.0 - 7.1.0
working days in the 53th week from 2015<br>02-01-2016<br>03-01-2016<br>04-01-2016<br>05-01-2016<br>06-01-2016<br><br>working days in the 1st week from 2016<br>02-01-2016<br>03-01-2016<br>04-01-2016<br>05-01-2016<br>06-01-2016<br><br>
Output for 5.0.0 - 5.0.5
working days in the 53th week from 2015<br>01-08-20150099<br>02-08-20150099<br>03-08-20150099<br>04-08-20150099<br>05-08-20150099<br><br>working days in the 1st week from 2016<br>01-12-20160103<br>02-12-20160103<br>03-12-20160103<br>04-12-20160103<br>05-12-20160103<br><br>
Output for 4.3.6 - 4.4.9
working days in the 53th week from 2015<br>27-12-1969<br>28-12-1969<br>29-12-1969<br>30-12-1969<br>31-12-1969<br><br>working days in the 1st week from 2016<br>27-12-1969<br>28-12-1969<br>29-12-1969<br>30-12-1969<br>31-12-1969<br><br>
Output for 4.3.0 - 4.3.5
working days in the 53th week from 2015<br><br><br><br><br><br><br>working days in the 1st week from 2016<br><br><br><br><br><br><br>