I am trying to display an "open" or "closed" graphic on a PHP page if the current date/time is between the stores opening times:
$mycurrentdateandtime = new DateTime();
$open = new DateTime( $mycurrentdateandtime->format('Y-m-d').' 09:30');
$close = new DateTime($mycurrentdateandtime->format('Y-m-d').' 17:00');
if (($mycurrentdateandtime >= $open) && ($mycurrentdateandtime <= $close)) {
echo 'yes we are open';
} else {
echo 'sorry we are closed';
}
I'm not great at PHP but the above works fine however I'd like to display "sorry we are closed" if it's either a Saturday or a Sunday. How can I edit the above code to check that?
Thank you. NJ
Aucun commentaire:
Enregistrer un commentaire