Created
April 26, 2012 09:28
-
-
Save beneverard/2498071 to your computer and use it in GitHub Desktop.
Calculate date from ISO 8601 week number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_week_number_date($week, $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 | |
return strtotime('-' . (date('w', $time) - 1) . ' days', $time); | |
} | |
get_week_number_date(14, 2012); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment