<?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>";
?>
preferences:
36.84 ms | 402 KiB | 5 Q