CODE
<?php
$time = array(
'current' => date('H'), // Current time, using the 24 hour time frame.
'late' => '24', // 12:00 AM.
'morning' => '6', // 6:00 AM.
'afternoon' => '12', // 12:00 PM.
'evening' => '19' // 7:00 PM.
);
$greeting = array(
'late' => 'Sleepy time',
'morning' => 'Good morning',
'afternoon' => 'Good afternoon',
'evening' => 'Good evening'
);
?>
$time = array(
'current' => date('H'), // Current time, using the 24 hour time frame.
'late' => '24', // 12:00 AM.
'morning' => '6', // 6:00 AM.
'afternoon' => '12', // 12:00 PM.
'evening' => '19' // 7:00 PM.
);
$greeting = array(
'late' => 'Sleepy time',
'morning' => 'Good morning',
'afternoon' => 'Good afternoon',
'evening' => 'Good evening'
);
?>
And in another file:
CODE
<?php
function greeting() {
global $time, $greeting;
if ($time['current'] >= $time['late'] && $time['current'] < $time['morning']) echo $greeting['late'];
else if ($time['current'] >= $time['morning'] && $time['current'] < $time['afternoon']) echo $greeting['morning'];
else if ($time['current'] >= $time['afternoon'] && $time['current'] < $time['evening']) echo $greeting['afternoon'];
else if ($time['current'] >= $time['evening'] && $time['current'] < $time['late']) echo $greeting['evening'];
}
?>
function greeting() {
global $time, $greeting;
if ($time['current'] >= $time['late'] && $time['current'] < $time['morning']) echo $greeting['late'];
else if ($time['current'] >= $time['morning'] && $time['current'] < $time['afternoon']) echo $greeting['morning'];
else if ($time['current'] >= $time['afternoon'] && $time['current'] < $time['evening']) echo $greeting['afternoon'];
else if ($time['current'] >= $time['evening'] && $time['current'] < $time['late']) echo $greeting['evening'];
}
?>
Now, this seems to work fine. It's currently giving me the correct message (afternoon time over here). It also works for the morning and evening messages. However, for some reason, it goes blank when it comes to the late message. I have a feeling it might because of the if and else if statements, but I doubt it.
Any ideas regarding this issue would be appreciated.