0

This tutorial shows how to greet your visitors depending on what time of day it is. If it's morning, it greets your visitor with "Good Morning!" If it's afternoon, it greets them with "Good Afternoon!" Magic? Noooo! Just PHP!

We will start by looking at the entire script and then dissecting it afterward.
The Tutorial of this so you cn understand will be piosted in the Tutorials Section of this site.

<?php

//Here we define out main variables
$welcome_string="Welcome!";
$numeric_date=date("G");

//Start conditionals based on military time
if($numeric_date>=0&&$numeric_date<=11)
$welcome_string="Good Morning!";
else if($numeric_date>=12&&$numeric_date<=17)
$welcome_string="Good Afternoon!";
else if($numeric_date>=18&&$numeric_date<=23)
$welcome_string="Good Evening!";

//Display our greeting
echo "$welcome_string";

?>
4
Contributors
4
Replies
5
Views
12 Years
Discussion Span
Last Post by LloydFarrell
0

Hey its nice to come back after sooooo many months and your cool looking snippets still here!

0

hi, i want to build login & register page useing php5.2& oracle 10g exp ed. can u help me

0

Hi, I was wondering how i could use your code snippet to determine the local time of users.

I am hosting with godaddy at the moment and the time difference is causing some minor time issues.

Is it possible, or how could i interact and retrieve the users local time ?

Hoping you reply positivley,

regards
lloyd

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.