Posted By

jkjeldgaard on 02/23/10


Tagged

php date


Versions (?)

get dates by week and year


 / Published in: PHP
 

/** * @param Int $week * @param Int $year * @return Array */

  1. public function getDaysInWeek($week, $year) {
  2. $week = sprintf('%02d',$week); //format as a 2 digit number. eg: 05
  3.  
  4. // set up ISO week date, eg: 2006W527, sunday(7), week 52 of 2006
  5. $daysInWeek = array();
  6. for ($day = 1;
  7. $day <= 7;
  8. $day++) {
  9. $ISOweekDate = $year . "W" . $week . $day;
  10. $daysInWeek[] = strtotime($ISOweekDate);
  11. }
  12.  
  13. return $daysInWeek;
  14. }

Report this snippet  

You need to login to post a comment.