Disable Monday after 16:00 on Saturday

I created a small function that disables the dates in my js calendar (which explains -1 month) after 16:00, the next date will be disabled. The business that I built for this is open Monday through Saturday, so there is a problem when it turns off Sunday on Saturday, but in fact it needs to be turned off Monday (next business day). How can I change my code to allow Monday to disconnect if it is after 4:00 p.m. on Saturday, saving other days?

My working code is:

$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;
}

Tried the code below does not work. It will disconnect the next day, but will not disconnect Monday if it is after 4 on Saturday

            $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;
        }
+3
source share
2 answers
<?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);
}

, -1 , . 2014-01-24, 24 jscal

+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);
}

+1

All Articles