1. Home
  2. Computing & Technology
  3. PHP / MySQL

Time Based PHP Greetings

By Angela Bradley, About.com

2 of 4

If it is AM

This bit of code would directly follow the code from the previous page.
if ($m == "AM")
{
if ($hour == 12)
{
echo "Good Evening!";
}
elseif ($hour < 4)
{
echo "Good Evening!";
}
elseif ($hour > 3)
{
echo "Good Morning!";
}
}
This code checks to see if the $m variable is AM. If it is AM it then checks to see what time it is using our $hour variable. If it is 12 AM (midnight) it tells the user "Good Evening!". It also says good evening if it is any time before 4AM. For times 4AM and later, it tells the user "Good Morning"!
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Step By Steps
  5. Time Based Greetings - PHP Greeting Script

©2009 About.com, a part of The New York Times Company.

All rights reserved.