1

我有一个客户想要一家在线比萨店,当然,他也不希望客户在营业时间之后下订单。我为此制作了一个简单的脚本,我想我可能会与将来想要的任何人分享。

4

1 回答 1

6
<?php
    date_default_timezone_set('Europe/Stockholm'); // timezone 

    $weekday = date('l'); // today 
    //print $weekday; // Debug
    //print date("H:i"); // debug

    // Set open and closing time for each day of the week
    if ($weekday == "Friday") {
        $open_from = "11:00";
        $opten_to = "21:45";
    }
    elseif ($weekday == "Saturday" || $weekday == "Sunday") {
        $open_from = "12:00";
        $open_to = "21:45";
    }
    else {
        $open_from = "11:00";
        $open_to = "20:45";
    }

    // now check if the current time is before or after opening hours
    if (date("H:i") < $open_from || date("H:i") > $open_to ) {
        echo "Closed!";
    }

    // show the checkout button
    else {
        echo "Open!";
    }
?>
于 2013-07-31T15:43:43.507 回答