To swap the background image from your CSS file according to the Server Clock Time.
1.) In your CSS file, add the following rule:
body {
background: url(time.png);
}
2.) Create a "folder" named time.png.
3.) Into the folder, place three images named morning.png, day.png, night.png.
4.) Also, in the same folder, create an index.php file and copy/paste the following script.
<?php
$hour = date('H');
if ($hour < 12 ) {
$image = "morning.png";
}
elseif ($hour < 17 ) {
$image = "day.png";
}
else {
$image = "night.png";
}
$image = imagecreatefrompng( "$image" );
if (!$image) { /* See if it failed */
header("(anti-spam-(anti-spam-content-type:)) image/png");
$im = imagecreatetruecolor (150, 30); /* Create a blank image */
$bgc = imagecolorallocate ($im, 255, 255, 200);
$tc = imagecolorallocate ($im, 0, 0, 0);
imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring ($im, 1, 5, 5, "Error loading Image", $tc);
imagepng($im);
imagedestroy($im);
die();
}
header("(anti-spam-(anti-spam-content-type:)) image/png");
imagepng($image);
imagedestroy($image);
?>
5.) Browse to your page and the background image should change according to the Server time clock.
Demo page: http://www.jlhaslip....s/misc/swap_bg/
Any questions?
















