
Image by hour
This is a short demonstration of how a different image may be included in a
web page at different times of day.
This script shows you Santa Clause from midnight to 8 a.m., Charlie the cat
until 4 p.m., and a gentelman supervising the horse racing at Larkhill from
4 p.m. until midnight.
Time Zone Issues arise - and you'll need to look into those and adjust
accordingly for your own situation. You'll also want to note that the time
used is the server time, not the browser time. In other words, if my server
is in California (which it is) and I'm browsing from the Ukraine, do I want
the image to show up based on California time, GMT, or (more difficult)
Ukraine time.
Current showing for hour 22
Well House Consultants, 2008
How do we do this?
Here's the code!
<?php
#%% different image to reflect time of day
$hour = date("G");
$image = "santa2";
if ($hour > 8) $image = "chsid";
if ($hour > 16) $image = "psh1";
?>
<html>
<head><title>Image of the hour</title></head>
<body>
<img src=/whimg/<?= $image ?>.jpg align=left hspace=5><h1>Image by hour</h1>
This is a short demonstration of how a different image may be included in a
web page at different times of day.<br><br>
This script shows you Santa Clause from midnight to 8 a.m., Charlie the cat
until 4 p.m., and a gentelman supervising the horse racing at Larkhill from
4 p.m. until midnight.<br><br>
<b>Time Zone Issues</b> arise - and you'll need to look into those and adjust
accordingly for your own situation. You'll also want to note that the time
used is the server time, not the browser time. In other words, if my server
is in California (which it is) and I'm browsing from the Ukraine, do I want
the image to show up based on California time, GMT, or (more difficult)
Ukraine time.
<br clear=all>
Current showing for hour <?= $hour ?><br>
Well House Consultants, <?= date("Y") ?><br>
<h1>How do we do this?</h1>
Here's the code!<br><br>
<?php highlight_file("houred.php"); ?>
</body></html>