// 傳回指定年份有多少週
function year_week_num($year){
$days = (checkdate(2, 29, $year) ? 366 : 365) + date("w", mktime(0,0,0,1,1 ,$year));
$mod = $days % 7;
return ($days-$mod) / 7 + ($mod>0 ? 1 : 0);
}
// 傳回指定年份第幾週開始及結束的日期
function year_week($year, $weekno){
if($year<1972) t =" (6-date(" t1 = "$year-01-01" t2 =" date("> year_week_num($year)) $weekno = year_week_num($year);
$t = (($weekno-2)*7 + (7-date("w", mktime(0,0,0,1,1, $year)))) * 86400;
$t1 = date("Y-m-d", mktime(0,0,0,1,1, $year) + $t);
$t2 = date("Y-m-d", mktime(0,0,0,1,1, $year) + $t+86400*6);
return array($t1, $t2);
}
沒有留言:
張貼留言