Change images according to Time

M

magix

Hi,

Do you have any javascript available for changing images according to time ?
let say Morning (7am-12pm), using images 1 (e.g morning.jpg)
Afternoon (12 - 6pm), using images 2 (e.g afternoon.jpg)
Night (6pm - 7am), using images 3 (e.g night.jpg)

thanks.

Magix
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Mon, 6 Mar 2006
03:52:30 remote, seen in magix
Do you have any javascript available for changing images according to time ?
let say Morning (7am-12pm), using images 1 (e.g morning.jpg)
Afternoon (12 - 6pm), using images 2 (e.g afternoon.jpg)
Night (6pm - 7am), using images 3 (e.g night.jpg)

If you had read the newsgroup FAQ, you should have found your way to js-
date0.htm#SS "Scheduled Selection" which can be simplified from hour-of-
week to hour-of-day.

It is not wise to divide the day into a.m. and p.m. within IT work; it
leads to unnecessary complication. Everyone should understand the
24-hour clock.

For only three images, you may prefer to use, rather than a List, a Case
statement, conditional statements, or a conditional expression such as
T<7 || T>18 ? "n.jpg" : T<12 ? "m.jpg" : "a.jpg"

You need to decide what you mean by, say, 6 pm; is it to be 18:00 UT,
18:00 Malaysian time, or 18:00 reader's time?

You also need to decide whether the image is chosen only when the page
loads, or whether it will be changed at 07:00, 12:00 and 18:00.

You could divide the day into equal intervals of Night, Morning,
Afternoon, and Evening, and use numbered images addressed as
Math.floor(T/6) + ".jpg"
or ((T/6)|0) + ".jpg"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top