Ever notice how Google changes its logo on different holidays throughout the year? I decided this morning I wanted to change the background color and some other themes on one of our websites.
With Halloween, Thanksgiving and Christmas coming I added some code this morning to one of our sites for implementing different background/theme switching so that it would automatically change the color scheme across the website during the holiday.
I did something similar to change the background color every day of the week in my PHP Diary: December 19, 1999 (and then the follow-up on December 20, 1999 a better version using an array instead of if/else statements). That background changing script has been running pretty much unmodified every day for nearly six years now.
How to change the background color of an HTML page only on Halloween and Christmas day
$background_color = ‘#FFF’; // default WHITE background
switch(date(“md”)) {
case 1031:
// automatic halloween background color (light orange) on 10/31
$background_color = ‘#FFE6CC’;
break;
case 1225:
// xmas day background color (light green) on 12/25
$background_color = ‘#D5FFD5′;
break;
}
?>
<body bgcolor=“<?php echo($background_color);?>”>
?>
To modify the script for other colors and holidays just add additional case blocks like say we wanted the background to be red for 4th of the July we’d add the following case block:
$background_color = ‘red’;
break;
And so on.

[…] Related How to change background color only on holidays Listen to this post […]
on July 14th, 2006 at 8:51 am | #Link Comment