Skip to content

Instantly share code, notes, and snippets.

@beneverard
Created April 26, 2012 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beneverard/2498071 to your computer and use it in GitHub Desktop.
Save beneverard/2498071 to your computer and use it in GitHub Desktop.
Calculate date from ISO 8601 week number
<?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