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

Time Based PHP Greetings

By , About.com Guide

1 of 4

Getting the Current Time

Before we can greet the user based upon the time of day, we first need to find out what time of day it is.
<?php

$b = time();

$hour = date("g",$b);
$m = date ("A", $b);

First we get the timestamp for the current date using the time () function. For the purpose of our script the only important parts are the hour and the AM/PM. We set a variable for each of these aspects of the time.
Explore PHP / MySQL
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. 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.