根據當前日期獲取下一週日期陣列
阿新 • • 發佈:2019-01-02
** * @return string 返回下一週日期陣列 */ function get_next_week($date){ $dates = array(); $time = strtotime($date.' 12:00:00'); $w = date('w', $time); if($w == 0){ $next = 1; } else { $next = 7 - $w + 1; } for($i = $next; $i<$next + 7; $i++){ $dates[] = date('Y-m-d', $time + 3600*24*$i); } return $dates; } $last_week = get_next_week(date('Y-m-d',time()-60*60*24*14)); array_unshift($last_week, array_pop($last_week));//週日移到陣列第一位
獲取上一週日期陣列