Jump to content

PHP Greeting


driz

Recommended Posts

Hi, I wanting to do a greeting based on the time of day,so for instance if its between 12pm and say 9pm you would get Good Evening, and then from 9pm until 12am, you would get Good Night, and then from 12am until 12pm you would get Good Morning.Thanks. x

Link to comment
Share on other sites

Just use the date object:

<?php$hour = idate("H");if($hour >= 12 && $hour < 21) {  echo "Good Evening";} else if($hour >= 21) {  echo "Good Night";} else {  echo "Good Morning";}?>

I use idate() instead of date() because it returns an integer.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...