Results 1 to 2 of 2

Thread: JavaScript local local time script 24 hr format?

  1. #1
    Join Date
    Feb 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JavaScript local local time script 24 hr format?

    Hi,

    Can someone please show me how to use a 24 hr format with the
    JavaScript local time script?, it has 12 hr by default.

    Thanks

    Ey

    Its located here
    http://www.dynamicdrive.com/dynamicindex6/localtime.htm



    Edit: mod's note:

    Welcome to DynamicDrive, eddiy!

    Please don't double-post.

    Sometimes, new posts are caught in the forum's anti-spam software. We review all moderated posts as soon as quickly as possible, so please be patient. Posting again only slows the process by increasing the amount of work we need to do.

    thanks!
    Last edited by traq; 02-15-2013 at 02:23 AM. Reason: mod's note

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,776
    Thanks
    2
    Thanked 411 Times in 406 Posts

    Default

    Code:
    showLocalTime.prototype.updateContainer=function(){
    var thisobj=this
    if (this.displayversion=="long")
    this.container.innerHTML=this.localtime.toLocaleString()
    else{
    var hour=this.localtime.getHours()
    var minutes=this.localtime.getMinutes()
    var seconds=this.localtime.getSeconds()
    var ampm=''
    var dayofweek=weekdaystxt[this.localtime.getDay()]
    this.container.innerHTML=formatField(hour, 1)+":"+formatField(minutes)+":"+formatField(seconds)+" "+ampm+" ("+dayofweek+")"
    }
    setTimeout(function(){thisobj.updateContainer()}, 1000) //update container every second
    }
    
    function formatField(num, isHour){
    if (typeof isHour!="undefined"){ //if this is the hour field
    }
    return (num<=9)? "0"+num : num//if this is minute or sec field
    }
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Similar Threads

  1. Local Time Script - Time Format
    By MizzBia in forum Dynamic Drive scripts help
    Replies: 8
    Last Post: 06-20-2011, 12:37 PM
  2. Local Time Script - remove seconds + 24hr format
    By i-conicdesign in forum JavaScript
    Replies: 1
    Last Post: 05-24-2011, 04:54 PM
  3. Local Time script - Switch to 24 h format?
    By londres9b in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 07-16-2010, 09:23 AM
  4. Help - Local Time script
    By mkts in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 10-23-2007, 02:13 AM
  5. Format time stamp to Local time zone
    By unitedlocalbands in forum JavaScript
    Replies: 2
    Last Post: 09-18-2007, 06:00 PM

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
  •