display the output if it a certain time of day i.e. 9am to 5pm

Hi guys

I have this little snippet below that shows the out put if it's not Sat or Sun

My question is I also only want it to display the output if it a certain time of day i.e. 9am to 5pm

Can any one help me out :)



$date = date("D");

if ($date != "Sat" OR $date != "Sun")

{
echo "Is't not Sat or Sun";
}
submissiontechnologyAsked:
Who is Participating?
 
keteracelCommented:
so adding it to the last one:

<?php

$hr = date("H");
$date = date("D");

if ($date != "Sat" OR $date != "Sun") {
  if ($hr > 9 && $hr < 17) {
    echo "Isn't Sat or Sun and is between 9am and 5pm...";
  }
}

?>
0
 
keteracelCommented:
<?

$hr = date("H");

if ($hr > 9 && $hr < 17) {
  echo "right time";
}

?>
0
 
rcmwizbitCommented:

You can use the date() function again to get the hour in 24 hour format...

$hour = date("G");

if ($hour > 8 && $hour < 17) {
 echo "Time between 08:59 and 16:59";
}

Hope this helps.
0
 
keteracelCommented:
oops, shoulda been $hr >= 9 not $hr > 9...
0
 
submissiontechnologyAuthor Commented:
Thanks chaps :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.