PHP封裝函數,獲取周日期
阿新 • • 發佈:2018-09-16
ndt cti vat star start span art rto pan
//周日期 private function get_week($date) { $date_week = date("W",strtotime($date)); //上周日期是第幾周 $week_num = date("w",strtotime($date)); //上周日期是星期幾 if($week_num == 0) $week_num = 7; $starttime = strtotime($date) - ($week_num-1)*24*3600; //哪一周開始的時間(因為開始時間直接設置為了周一) $endtime = strtotime($date) + (7-$week_num +1)*24*3600 -1; //哪一周結束的時間 return array( ‘starttime‘ => $starttime, //上周的星期一 ‘endtime‘ => $endtime, //上周的星期日 ‘date‘ => $date, ‘week_num‘ => $week_num, //星期幾 ‘date_week‘ => date("o",$starttime).‘-‘.$date_week //上周是第幾周 ); }
PHP封裝函數,獲取周日期