PDA

View Full Version : Local Time script - Switch to 24 h format?



londres9b
07-15-2010, 08:25 PM
1) Script Title: Local Time script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex6/localtime.htm

3) Describe problem: That script is really great! It displays the server time and updates it to the second! Thanks DD.

But I was wondering if it is possible to make the time display in the 24 hour format?

Can anyone help plz? T.I.A.

djr33
07-16-2010, 02:25 AM
Easy. Just replace this line:
var hour=(num>12)? num-12 : num
With:
var hour=num;


Also, you probably want to fix this:
var ampm=(hour>=12)? "PM" : "AM"
to:
var ampm=""; (now it's blank)

You could remove it entirely, by removing that line (above), then deleting ampm from:
this.container.innerHTML=formatField(hour, 1)+":"+formatField(minutes)+":"+formatField(seconds)+" "+ampm+" ("+dayofweek+")"
To:
this.container.innerHTML=formatField(hour, 1)+":"+formatField(minutes)+":"+formatField(seconds)+" ("+dayofweek+")"

londres9b
07-16-2010, 09:23 AM
Many many Thanks! :)