Results 1 to 2 of 2

Thread: JS Clock

  1. #1
    Join Date
    Jan 2011
    Location
    England
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question JS Clock

    Hey, I have a JS clock in my webpage.

    I was wondering how to align it to the bottom+middle. Do I use the align and valign attributes?

    I'm very new to JS so bear with me!

    Thank you all in advance for any guidance!

  2. #2
    Join Date
    Jan 2011
    Posts
    50
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    hi there..

    here's a script a can share with you...


    function startTime() {
    var today = new Date();
    var h = today.getHours();
    var m = today.getMinutes();
    var s = today.getSeconds();
    // add a zero in front of numbers<10
    m = checkTime(m);
    s = checkTime(s);
    document.getElementById('txt').innerHTML = h + ":" + m + ":" + s;
    t = setTimeout('startTime()', 500);
    }

    function checkTime(i) {
    if (i < 10) {
    i = "0" + i;
    }
    return i;
    }



    so the clock here is aligned on the right side...you can change if you want it somewhere else...

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
  •