Forum Moderators: open

Message Too Old, No Replies

How to change this to hours instead of days?

         

Simone100

6:20 am on Oct 20, 2006 (gmt 0)

10+ Year Member



var mydate = new Date();
var mytoday = mydate.getDate();

How to change that to hours instead of days. I tried just changing
it to hours right before the brackets but it won't work.

Please let me know, thanks.

Simone100

7:52 am on Oct 20, 2006 (gmt 0)

10+ Year Member



OK I got it, I forgot to capitalize the "H" in getHours.

I am puzzled though. When I use this it starts on the first hour instead of the hours we are in.

But when I use date it starts on the correct date. Anyone know whats up with that? Please let me know, thanks!

DrDoc

8:00 am on Oct 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mydate.getHours()
should print the current hour. Not sure why it doesn't do that for you. For example, if the time is 8:35 am,
getHours()
returns 8, and
getMinutes()
returns 35.

Simone100

8:57 am on Oct 20, 2006 (gmt 0)

10+ Year Member



I found out what my problem is. It doesn't keep going. It only shows the new hour on page load. Anyway to have it automatically change to the new hour while the page stays open?

inveni0

11:26 am on Oct 20, 2006 (gmt 0)

10+ Year Member



You'll need to write code to:

1) update the clock every second
or
2) get the time and count the seconds on its own