$time = time(); // 可设定日期
$week_day_num = date('w', $time);
if ($week_day_num == 0) {
// 当前是周日的情况
$sdate = date('Y-m-d', strtotime("-6 day", $time));
$edate = date('Y-m-d', $time);
} else {
$sdate = date('Y-m-d', strtotime("-" . ($week_day_num - 1) . " day", $time));
$edate = date('Y-m-d', strtotime("+" . (7 - $week_day_num) . " day", $time));
date('w', time()); 输出出来的是数字星期几,转换成文字如下:
1 2 3 4 5 6 7 8 |
|
把别人写的整理一起了,还有下面两个链接,做个笔记