get dates by week and year


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.