Home >Backend Development >PHP Tutorial >Get month date based on week

Get month date based on week

WBOY
WBOYOriginal
2016-07-25 09:06:241132browse
Get month date based on week
  1. /**
  2. * Get the month date based on the week
  3. * @param int $weenNum Week 0-6
  4. * @return array $days Return the date array
  5. */
  6. public function getDateByWeek($weekNum,$month,$year)
  7. {
  8. $totalDays=date('t',strtotime(mktime(0,0,0,$month ,1,$year)));//Calculate the total number of days in the month
  9. $days=array();
  10. for($day=1;$day<=$totalDays;$day++)
  11. {
  12. $mkTime=mktime(0 ,0,0,$month,$day,$year);
  13. if(date('w',$mkTime)==$weekNum){
  14. $days[]=date('Y-m-d',$mkTime) ;
  15. }
  16. }
  17. return $days;
  18. }
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn