SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Jquery Clock

  1. #1
    SitePoint Member
    Join Date
    Jul 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jquery Clock

    Hello, Would you plz tell me how can get a good jQuery code for making a clock on my website?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,114
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    There's a lot of info on the web about this, so best to Google this kind of question first. Here's the first thing I found on Google:

    http://www.jquery4u.com/plugins/10-c...nalog-digital/
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  3. #3
    Non-Member
    Join Date
    Jun 2012
    Posts
    88
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Why use jquery? It's only a few lines of code using plain javascript. If you use jquery, you'll be running a lot more code in the background.

    Code:
        <body>
            <div id="clockContainer">
                <span id="spHrs"></span> : <span id="spMins"></span> : <span id="spSecs"></span>
            </div>
            
            <script type="text/javascript">
                function showTime(){
                        var timeNow = new Date(); 
                        document.getElementById('spHrs').innerHTML = timeNow.getHours();
                        document.getElementById('spMins').innerHTML = timeNow.getMinutes();
                        document.getElementById('spSecs').innerHTML = timeNow.getSeconds();
                }
                setInterval(showTime,1000);
        </script>
        </body>

    But in any case, you''re probably better off using a server side clock because what about if the user's local clock time is incorrect?


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
  •