New graphic display at different times of the day

message from adam1710 on 19 Jul 2004
I am building a web site for an on-line radio station and they want a new
graphic (gif) to be displayed at different times of the day to tie in with what
presenter etc is currently on air. The site is www.neradio.net can anyone let
me know how this could be done. Thanks
 
Mick White replied to adam1710 on 19 Jul 2004
This could be easily accomplished with javascript, but there's a
minority out there who don't have js enabled.
<script>
var im= ["nightowl.gif","am.gif","noon.gif","drivetime.gif",
"evening.gif","night.gif"]
h=new Date().getHours()// user's local time
theImage = h<6?im[0]:h<12?im[1]:h<15?im[2]:h<19?im[3]:h<22?im[4]:im[5];
document.write("<img src='"+theImage+"' >")
</script>

Non js browsers will not see an image.
Explanation:
12am-4:59am: nightowl.gif
5am-10:59am: am.gif
11am-1:59pm: noon.gif
2pm -5:59pm: drivetime.gif
6pm -8:59pm: evening.gif
9pm-11:59pm: night.gif

Mick

adam1710 wrote:
 
darrel replied to Mick White on 19 Jul 2004
The big problem is that it would be based on the end-user's time...not the
radio station's time zone.

That could be an issue...especially if they web-cast.

-Darrel
 
Mick White replied to darrel on 20 Jul 2004
offset=300 //(minutes)
//The user's offset
userOffset=new Date().getTimezoneOffset()
differenceInHours=(offset-userOffset)/60

negative is earlier(to the west).

Mick

darrel wrote:
 
darrel replied to adam1710 on 19 Jul 2004
Are you using any server-side scripting? You will for this to work.

You could then just do something like this:

currentTime = get Server Time
select currentTime
case currentTime < 4pm and currentTime > 3pm
show image 1
case currentTime < 5pm and currentTime > 3pm
show image 2
etc...

-Darrel
 

Archived message: New graphic display at different times of the day (Macromedia Dreamweaver)