Get month date based on week
- /**
- * Get the month date based on the week
- * @param int $weenNum Week 0-6
- * @return array $days Return the date array
- */
- public function getDateByWeek($weekNum,$month,$year)
- {
- $totalDays=date('t',strtotime(mktime(0,0,0,$month ,1,$year)));//Calculate the total number of days in the month
- $days=array();
- for($day=1;$day<=$totalDays;$day++)
- {
- $mkTime=mktime(0 ,0,0,$month,$day,$year);
- if(date('w',$mkTime)==$weekNum){
- $days[]=date('Y-m-d',$mkTime) ;
- }
- }
- return $days;
- }
Copy code
|