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

Get month date based on week

WBOY
Release: 2016-07-25 09:06:24
Original
1161 people have browsed it
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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template