#native_company# #native_desc#
#native_cta#

Dynamic Greeter Script

By Stephen Ward
on June 17, 2002

Version: 1.0

Type: Full Script

Category: Calendars/Dates

License: GNU General Public License

Description: A PHP script that retrieves date and time information and spits out a tailored greeting. The script outputs a greeting based on most common United States holidays and defaults to a generic “Good morning/afternoon/evening” on non-holidays.

<?php

// Set date/time variables.
$time=getdate();
$hour=$time['hours'];
$day=$time['mday'];
$month=$time['mon'];
$wday=$time['wday'];
$wdnum=(int)(($day+6)/7);
if (strlen($month)==1){$mm="0".$month;}
else {$mm=$month;}
if (strlen($day)==1){$dd="0".$day;}
else {$dd=$day;}
$mmdd=$mm.$dd;
$nwmm=$wdnum.$wday.$mm;

// Check for holidays with set dates.
switch ($mmdd){
case "0101":
case "1231":
$greet="Happy New Year";
break;
case "0202":
$greet="Happy Groundhog's Day";
break;
case "0214":
$greet="Happy Valentine's Day";
break;
case "0317":
$greet="Happy St. Patrick's Day";
break;
case "0422":
$greet="Happy Earth Day";
break;
case "0614":
$greet="Happy Flag Day";
break;
case "0704":
$greet="Happy Independence Day";
break;
case "1031":
$greet="Happy Halloween";
break;
case "1111":
$greet="Happy Veteran's Day";
break;
case "1225":
$greet="Merry Christmas";
break;
default:
unset($mmdd);
break;}

// Check for holidays with variable dates.
switch ($nwmm){
case "3102":
$greet="Happy President's Day";
break;
case "2005":
$greet="Happy Mother's Day";
break;
case "3006":
$greet="Happy Father's Day";
break;
case "1109":
$greet="Happy Labor Day";
break;
case "4511":
$greet="Happy Thanksgiving";
break;
default:
unset($nwmm);
break;}

// Check for Memorial Day or default to a standard daily greeting.
if (isset($greet)){}
elseif ($mm==05&&$dd>24&&$wday==1){$greet="Happy Memorial Day";}
elseif (empty($mmdd)&&empty($nwmm)){
	if ($hour<=4){$greet="Good evening";}
	elseif ($hour>=5&&$hour<12){$greet="Good morning";}
	elseif ($hour>=12&&$hour<18){$greet="Good afternoon";}
	elseif ($hour>=18){$greet="Good evening";}}
else {$greet="Hello";}

echo $greet;

?>