Jump to content

How do you echo date functions on certain times of the day??


harryuk

Recommended Posts

Hello fellow php friends, Im having abit of trouble trying to echo out a statement at certain times of the day.

for example

how would you echo out 'Good Morning' between the times of 01am to 11.59am

then echo out 'Good afternoon' between times of 12pm and 6pm and so on.

 

Please  help!!!!! :D :D

Link to comment
Share on other sites

$time = date('G');
if(($time == '1') || ($time > '1' && $time < '12')) {
echo 'Good morning!';
}
elseif(($time == '12') || ($time > '12' && $time < '18') {
echo 'Good afternoon!';
}
else {
echo 'Good night!';
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.