我使用以下代码,显示基于当前日期的日期,即如果今天是星期一或星期二,它应该显示下星期三的日期,如果有任何其他日期,它应该显示下星期一的日期。
代码如下:
<?php
$date = str_replace("/", "-", $date);
$nextWed = date("l jS F, Y",strtotime('next wednesday'));
$nextMon = date("l jS F, Y",strtotime('next monday'));
if(date('D', $timestamp) === 'Mon' or date('D', $timestamp) === 'Tue' ){
echo '<div class="time-note">Order your box before Tuesday 11.59pm and get it delivered on '.$nextWed .'</div>';}
else {
echo '<div class="time-note">Order your box before Sunday 11.59pm and get it delivered on '.$nextMon.'</div>';}?>
如果我今天查看输出,它仍然响应Order your box before Sunday 11.59pm and get it delivered on Monday 19th October 2015
。而应该写Order your box before Tuesday 11.59pm and get it delivered on Monday 14th October 2015
你唯一缺少的是$timestamp
在$nextMon = date("l jS F, Y",strtotime('next monday'));
下面直接添加$timestamp = time();
行
改变这一行
if(date('D') === 'Mon' or date('D') === 'Tue' )