2014-05-10 129 views
0

我找到返回给定日期的星期编号的函数。 但是,我希望得到返回特定日历周的第一天的日期。 这可以是date()本身,也可以是date() - 1和date() - 7之间的任何值。从当前日期()中获取日历周的开始位置

目的:我的网站将返回本周的活动。现在,我只显示范围date()+ 7,这是不正确的。

感谢&问候, 马库斯

回答

0

使用strtotime()功能是这样的:

strtotime("next monday"); 
strtotime("this sunday"); 
strtotime("last sunday"); 

你的情况:

strtotime("this monday"); 

当你有时间戳的结果。

第二种方式是这样的:

$day = date('w'); 
$week_start = date('m-d-Y', strtotime('-'.$day.' days')); 
$week_end = date('m-d-Y', strtotime('+'.(6-$day).' days')); 
相关问题