Help - Need php to display different pages based on time and day of week

This is an alternative version, taking on board the comments.
The check is now a function, and the time checks use machine friendly integers rather than human friendly time strings. I removed the leading zeros and added seconds for a little more precision. Though I think I prefer the time strings, as it’s less confusing for anyone to edit if opening times change, and they do seem to work, which did surprise me.
And yes, I know the minutes and seconds are not decimals, but does it matter?

<?php
function timecheck() {
  $open = false ;
  $day = date('N') ;
  $time = date('Gis') ; // The time in HMMSS format
  if ( $time > 65959) {
   if (( $day < 5 ) && ( $time < 193001)) { $open = true ; }
   elseif (( $day == 5 ) && ( $time < 183001)) { $open = true ; }
   elseif (( $day == 6 ) && ( $time < 173001)) { $open = true ; }
 }
 return $open ;
} // end of function
 $open = timecheck();
 if ($open) { echo "<h1>We are Open!</h1>"; }
 else { echo "<h1>We are Closed!</h1>" ; }
?>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.