|
Posted by Thomas Blake on 11/01/06 23:54
Hi,
I am trying to create an IF statement that will display a message for a
school (depending on the time of day) as to what period / class it is.
The class times are:
Period 1: 9 AM - 9:59 AM
Period 2: 10 AM - 10:59 AM
Recess: 11 AM - 11:29 AM
Period 3: 11:30 AM - 12:29 PM
Period 4: 12:30 PM - 1:29 PM
Lunch: 1:30 PM - 1:59 PM
Period 5: 2:00 PM - 3:00 PM
What I have so far is:
$todayhour = date("h"); // displays 09, 10, 11 etc
$todayminute = date("i"); // displays the minute 01, 11, 25 etc
$todayampm = date("A"); // displays AM or PM
if ($todayhour == "09" AND $todayampm == "AM" )
{
$period = "It is currently Period 1";
}
elseif ($todayhour == "10" AND $todayampm == "AM" )
{
$period = "It is currently Period 2";
}
elseif ($todayhour == "12" AND $todayampm == "PM" )
{
$period = "It is currently Period 3";
}
elseif ($todayhour == "01" AND $todayampm == "PM" )
{
$period = "It is currently Period 4";
}
elseif ($todayhour == "02" AND $todayampm == "PM" )
{
$period = "It is currently Period 5";
}
else
{
$period = "School is not currently in";
}
?>
This program works to a certain extent, I am unsure how to incorporate
things such as recess and lunch that go from 11:00 - 11:29 and 1:30 - 1:59
Any help would be greatly appreciated
Thanks,
Tom
Navigation:
[Reply to this message]
|