如何查找给定年份和周数的一周的开始和结束日期? 它用于在Hr模块项目的工作班次中插入每个员工的周日期,所以请帮助我
提前致谢, 婆
答案 0 :(得分:0)
function Start_End_Date_of_a_week($week, $year){
$time = strtotime("1 January $year", time());
$day = date('w', $time);
$time += ((7*$week)+1-$day)*24*3600;
$dates[0] = date('Y-n-j', $time);
$time += 6*24*3600;
$dates[1] = date('Y-n-j', $time);
return $dates;
}
$result = Start_End_Date_of_a_week(35,1998);
echo 'Starting date of the week: '. $result[0]."\n";
echo 'End date the week: '. $result[1];