PDA

View Full Version : HTML/javascript time-based page. How?


rm_stealth
03-11-2009, 09:16 AM
I wish to create a web page that, depending on the current GMT time, gives certain output. Eg:

if the time is between 12 AM and 4 AM, output 1

or if between 4 AM and 10 PAM, output 2 etc

I can use HTML and Javascript in this page

How should I go about it?

omnicity
03-11-2009, 12:28 PM
Do you just need to do this once, (on page load)
or continuously,
or in response to some other event?

Either way, your code is going to need to be based around a
new Date()
followed by some comparisons on getHour() or getUTCHour() depending on your needs: is it the local time, or the server time that matters?

rm_stealth
03-11-2009, 09:59 PM
Basically what I need is this:

Times:
A-B
B-C
C-D
D-A

If the time is between A and B, I need a countdown to C, if between B-C, a countdown to D etc. This is based only on the UTC time, not on the date.

And obviously, its continuously, since its a continuous countdown.