date - Opening hours in PHP -
i had client wanted online pizza shop, , didn't want customers place orders after opening hours - of course. made little simple script that, thought might share wants in future.
<?php date_default_timezone_set('europe/stockholm'); // timezone $weekday = date(l); // today //print $weekday; // debug //print date("h:i"); // debug // set open , closing time each day of 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"; } // check if current time before or after opening hours if (date("h:i") < $open_from || date("h:i") > $open_to ) { print "closed!"; } // show checkout button else { print "open!"; } ?>
Comments
Post a Comment