Php 星期六下午4:00后禁用星期一

Php 星期六下午4:00后禁用星期一,php,datetime,Php,Datetime,我已经建立了一个小功能,在我的js日历上禁用日期(这将解释-1个月),下午4点之后,接下来的日期将被禁用。我为其创建的业务是星期一-星期六开放的,因此当它是星期六时会出现问题,它将禁用星期天,但实际上它需要禁用星期一(他们的下一个工作日)。如果星期六下午4:00之后是星期一,我如何编辑代码以允许禁用星期一,而保留其他日期 我的工作代码: $datetime = new DateTime(); $deadline = new DateTime("today 4:00PM"); $today =

我已经建立了一个小功能,在我的js日历上禁用日期(这将解释-1个月),下午4点之后,接下来的日期将被禁用。我为其创建的业务是星期一-星期六开放的,因此当它是星期六时会出现问题,它将禁用星期天,但实际上它需要禁用星期一(他们的下一个工作日)。如果星期六下午4:00之后是星期一,我如何编辑代码以允许禁用星期一,而保留其他日期

我的工作代码:

$datetime = new DateTime();

$deadline = new DateTime("today 4:00PM");

$today = new Datetime('today');

$todays = $today->format('Y-m-d');

$db_date = strtotime($todays);

$todaydisable = date('Y-m-d', strtotime("-1 month", $db_date));

if($datetime > $deadline){
    $tomorrow = Date("Y,m,d", strtotime("+1 day -1 month "));

} else {
    $tomorrow = NULL;
}
尝试了下面的代码也不起作用它将在第二天禁用,但如果是星期六4点以后,则不会在星期一禁用

            $now      = new DateTime("-1 month");
        $deadline = clone $now;
        $deadline->setTime(4, 00);
        if ($now > $deadline) {
            $now->modify('+1 day');
            $when = ('-1 month Saturday' === $now->format('l')) ? '-1 month Next Monday' : '-1 month Tomorrow';
            $tomorrow = new DateTime($when);
            $tomorrowFormat = $tomorrow->format('Y,m,d');
        } else {
            $tomorrowFormat = NULL;
        }

似乎工作不正常。它似乎在当前日期后的第二个月禁用了。更改前:|更改后:我更新了代码:$now=new DateTime();$deadline=clone$now;$deadline->setTime(4,00);如果($now>$DETAILE){$now->modify('+1天');$when=('Saturday'====$now->format('l'))?“-1个月下周一”:“-1个月明天”;$TOORROWFORMAT=新日期时间($when);$TOORROWFORMAT=$TOORY->格式('Y,m,d');}否则{$TOORROWFORMAT=NULL;}。这是我的var_dump:string(10)“2014,01,23”所以它返回的是星期天而不是星期一?@Lynx修改了代码,删除了修改+1天,现在应该可以工作了,这里有一把工作小提琴:
<?php
$now      = new DateTime();
$deadline = clone $now;
$deadline->setTime(16, 00);
if ($now > $deadline) {
    $now->modify('+1 day');
    $when = ('Saturday' === $now->format('l')) ? 'Next Monday' : 'Tomorrow';
    $tomorrow = new DateTime($when);
}
<?php
$now= new DateTime();
$deadline = clone $now;
$deadline->setTime(16, 00);
if ($now > $deadline) {
    //$now->modify('+1 day');
    $when = ('Saturday' === $now->format('l')) ? '-1 Month Next Monday' : '-1 Month Tomorrow';
    $tomorrow = new DateTime($when);
}