php 获取星期开始与星期结束的时间戳(使用中国星期 周一 为第一天)
获取当前星期的开始与结束时间戳
$data=getWeekStaAndEndTime(date("Y-m-d"));
print_r($data);
function getWeekStaAndEndTime($todayDate){
$da = date("w",strtotime($todayDate));
switch($da){
case 0:
$weekStart = date('Y-m-d',strtotime($todayDate.' -6 day'));
$weekOver = $todayDate;
break;
case 1:
$weekStart = $todayDate;
$weekOver = date('Y-m-d',strtotime($todayDate.' +6 day'));
break;
case 2:
$weekStart = date('Y-m-d',strtotime($todayDate.' -1 day'));
$weekOver = date('Y-m-d',strtotime($todayDate.' +5 day'));
break;
case 3:
$weekStart = date('Y-m-d',strtotime($todayDate.' -2 day'));
$weekOver = date('Y-m-d',strtotime($todayDate.' +4 day'));
break;
case 4:
$weekStart = date('Y-m-d',strtotime($todayDate.' -3 day'));
$weekOver = date('Y-m-d',strtotime($todayDate.' +3 day'));
break;
case 5:
$weekStart = date('Y-m-d',strtotime($todayDate.' -4 day'));
$weekOver = date('Y-m-d',strtotime($todayDate.' +2 day'));
break;
case 6:
$weekStart = date('Y-m-d',strtotime($todayDate.' -5 day'));
$weekOver = date('Y-m-d',strtotime($todayDate.' +1 day'));
break;
default:
}
$weekStartTime = strtotime($weekStart.' 0:0:0');
$weekOverTime = strtotime($weekOver.' 23:59:59');
$data = [
"weekStartTime" => $weekStartTime,
"weekOverTime" => $weekOverTime
];
return $data;
}
THE END
0
二维码
海报
php 获取星期开始与星期结束的时间戳(使用中国星期 周一 为第一天)
获取当前星期的开始与结束时间戳
$data=getWeekStaAndEndTime(date("Y-m-d"));
print_r($data);
function getWeekStaAndEndTime($todayDate……
上海网站建设