[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2005-05-16
5
Medium Priority
?
266 Views
Last Modified: 2006-11-18
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";
}
0
Comment
Question by:submissiontechnology
  • 3
5 Comments
 
LVL 9

Expert Comment

by:keteracel
ID: 14008792
<?

$hr = date("H");

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

?>
0
 
LVL 2

Expert Comment

by:rcmwizbit
ID: 14008799

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
 
LVL 9

Accepted Solution

by:
keteracel earned 2000 total points
ID: 14008800
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
 
LVL 9

Expert Comment

by:keteracel
ID: 14008808
oops, shoulda been $hr >= 9 not $hr > 9...
0
 

Author Comment

by:submissiontechnology
ID: 14008857
Thanks chaps :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question