Results 1 to 2 of 2

Thread: Jquery Clock Question

  1. #1
    Join Date
    Jun 2011
    Posts
    10

    Jquery Clock Question

    So I have this corny idea to make a clock with two hour hands. One hand showing the client's local time and the other showing my time (Central Standard Time). I have the clock working and showing the client's time, however I can't figure out how to add another hour hand showing my time. Does anyone have any ideas how this can be done??? Here's the I have right now.


    <head>

    <title>Clock</title>

    <script type="text/javascript" src="jquery-1.2.6.min.js"></script>

    <style type="text/css">
    * {
    margin: 0;
    padding: 0;
    }

    #clock {
    position: relative;
    width: 600px;
    height: 600px;
    margin: 20px auto 0 auto;
    background: url(images/clockface.jpg);
    list-style: none;
    }

    #sec, #min, #hour {
    position: absolute;
    width: 30px;
    height: 600px;
    top: 0px;
    left: 285px;
    }

    #sec {
    background: url(images/sechand.png);
    z-index: 4;
    }

    #min {
    background: url(images/minhand.png);
    z-index: 3;
    }

    #hour {
    background: url(images/hourhand.png);
    z-index: 2;
    }

    p {
    text-align: center;
    padding: 10px 0 0 0;
    }
    </style>

    <script type="text/javascript">

    $(document).ready(function() {

    setInterval( function() {
    var seconds = new Date().getSeconds();
    var sdegree = seconds * 6;
    var srotate = "rotate(" + sdegree + "deg)";

    $("#sec").css({"-moz-transform" : srotate, "-webkit-transform" : srotate});

    }, 1000 );


    setInterval( function() {
    var hours = new Date().getHours();
    var mins = new Date().getMinutes();
    var hdegree = hours * 30 + (mins / 2);
    var hrotate = "rotate(" + hdegree + "deg)";

    $("#hour").css({"-moz-transform" : hrotate, "-webkit-transform" : hrotate});

    }, 1000 );


    setInterval( function() {
    var mins = new Date().getMinutes();
    var mdegree = mins * 6;
    var mrotate = "rotate(" + mdegree + "deg)";

    $("#min").css({"-moz-transform" : mrotate, "-webkit-transform" : mrotate});

    }, 1000 );

    });

    </script>

    </head>

    <body>

    <ul id="clock">
    <li id="sec"></li>
    <li id="hour"></li>
    <li id="min"></li>
    </ul>

    </body>
    I didn't come up with this code, it came from here but I understand the html and css involved and I have a pretty good understanding of the jquery as well (I'm not super comfortable with Jquery just yet). My figuring is that i should just add another <li> with and id of hour2 or something. My only problem comes with the jquery... I have no idea how to make that hour hand show a specific time zone....

  2. #2
    Join Date
    Jun 2011
    Posts
    10
    Well I got no responses but just in case anybody was wondering I did find a cheap fix for this. Since the person I'm doing this for lives in pacific time zone and I live in Central time zone she's always 2 hours behind me. So if I just bump the degrees it rotates by + 60 then that will push the local time 2 hours ahead. It's not a great fix because it doesn't exactly do what I want but it's a temporary solution until I can figure out a better way to do it.

Similar Threads

  1. FLASH clock .getUTC not working
    By bolszo in forum Graphic Design
    Replies: 1
    Last Post: 10 Mar 2011, 04:29 AM
  2. jQuery: jCarousel specific implementation question
    By MultipleParadox in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 04 May 2009, 01:13 PM
  3. Countdown clock script
    By Frenchiexno1 in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 25 Feb 2006, 07:10 PM

Posting Permissions

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