这就是:
如果本周星期五少于10:00,则创建包含前一周的星期六的数组,则在本周的星期日、星期一、星期二、星期三和星期五进行数组。
如果现在在本周星期五超过10:00,则用包含本星期的星期六的另一个数组替换之前的数组,然后是下一周的星期日、星期一、星期二和星期五。
我不能用脚本来表达这种情况的逻辑。
谢谢
在读了很多很多帖子之后,我来到这个不起作用的地方。
$current_time = strtotime('now');
$week_start_day = "friday";
$start_time = "10:00";
if ($current_time <= strtotime('$week_start_day this week $start_time')) {
$day_1 = date('d/m/Y', strtotime('previous week friday', strtotime(date('d-m-Y'))));
$day_2 = date('d/m/Y', strtotime('previous week saturday ', strtotime(date('d-m-Y'))));
$day_3 = date('d/m/Y', strtotime('previous week sunday ', strtotime(date('d-m-Y'))));
$day_4 = date('d/m/Y', strtotime('previous week monday', strtotime(date('d-m-Y'))));
$day_5 = date('d/m/Y', strtotime('previous week tuesday', strtotime(date('d-m-Y'))));
$day_6 = date('d/m/Y', strtotime('this week wednesday ', strtotime(date('d-m-Y'))));
$day_7 = date('d/m/Y', strtotime('this week thursday ', strtotime(date('d-m-Y'))));
}
else{
$day_1 = date('d/m/Y', strtotime('this week saturday ', strtotime(date('d-m-Y'))));
$day_2 = date('d/m/Y', strtotime('this week sunday', strtotime(date('d-m-Y'))));
$day_3 = date('d/m/Y', strtotime('this week monday', strtotime(date('d-m-Y'))));
$day_4 = date('d/m/Y', strtotime('this week tuesday ', strtotime(date('d-m-Y'))));
$day_5 = date('d/m/Y', strtotime('this week wednesday ', strtotime(date('d-m-Y'))));
$day_6 = date('d/m/Y', strtotime('this week thursday ', strtotime(date('d-m-Y'))));
$day_7 = date('d/m/Y', strtotime('this week friday ', strtotime(date('d-m-Y'))));
}
echo "
$day_1 <br>
$day_2 <br>
$day_3 <br>
$day_4 <br>
$day_5 <br>
$day_6 <br>
$day_7 <br>
";发布于 2015-01-05 12:55:13
如果我对你的理解是正确的,这就是你想要的,没有很好的测试,所以可能会有错误,但这就是想法。
$fri=strtotime(" Friday this week + 4 hours ");// 10:00 GMT
$now=time();
$week=array();
if($now<=$fri)
{
$day = "last Saturday";
}
else
{
$day = "next Saturday";
}
for($i=0;$i<7;$i++)
{
$week[] = date("d/m/Y", strtotime($day." +".$i." day"));
}
foreach($week as $day)
{
echo $day;
}https://stackoverflow.com/questions/27778957
复制相似问题