Results 1 to 3 of 3

Thread: Local Time script - Switch to 24 h format?

  1. #1
    Join Date
    Jul 2010
    Location
    Portugal
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Local Time script - Switch to 24 h format?

    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.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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+")"
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2010
    Location
    Portugal
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Many many Thanks!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •