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

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -