PHP / MySQL

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

Time Based PHP Greetings

By Angela Bradley, About.com

3 of 4

If it is PM

This bit of code would directly follow the code from the previous page.
elseif ($m == "PM")
{
if ($hour == 12)
{
echo "Good Afternoon!";
}
elseif ($hour < 7)
{
echo "Good Afternoon!";
}
elseif ($hour > 6)
{
echo "Good Evening!";
}
}
?>
This code checks to see if the $m variable is PM. If it is PM it then checks to see what time it is using our $hour variable. If it is 12 PM (noon) it tells the user "Good Afternoon!". It also says good afternoon if it is any time before 7PM. For times 7PM and later, it tells the user "Good Evening"!

Explore PHP / MySQL

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

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

PHP / MySQL

  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.