Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8411113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:21:31+00:00 2026-06-10T00:21:31+00:00

I am trying to create world clock using the following JavaScript code. The clock

  • 0

I am trying to create world clock using the following JavaScript code.
The clock is showing on the screen but its not ticking. My aim is to add clocks for different time zones in the same screen. I can add several clocks but they are not ticking.

    <script language="javascript">

    var timerRunning = false;
    var timezone = "Greenwich Mean Time";  // what time zone are you in ?
    var adjust = 0;

    function timeCheck(diff) {

            if (timerRunning) {
                clearTimeout(updatetime);
                timerRunning = false; 
            }

            gmtOffset = eval(diff);

            var tdate_01 = new checkDateTime("zonetime");
            var tdate_02 = new checkDateTime("testt");
    }

    function checkDateTime(clckID) {

            var today = new Date();
            var year = today.getYear() + 1900;
            var month = today.getMonth()+1;
            var date = today.getDate();
            var day = today.getDay();
            var hour = today.getHours();
            var minute = today.getMinutes();
            var second = today.getSeconds();

            var lastSat = date - (day+1);
            while (lastSat < 32) lastSat+=7;
            if (lastSat > 31) lastSat+=-7;
            var firstSat = date - (day+1);
            while (firstSat > 0) firstSat+=-7;
            if (firstSat < 1) firstSat+=7;
            if ((((month == 4) && (date >= firstSat)) || month > 4) &&
            (month < 11 || ((month == 10) && day <= lastSat))) adjust += 60;
            yourOffset = (new Date()).getTimezoneOffset();
            yourOffset = yourOffset + adjust;

            var xx = navigator.appName
            var xy = navigator.appVersion;
            xy = xy.substring(0,1);
            if ((xy == 4) && (xx == "Netscape")) yourOffset = yourOffset+adjust;
            if ((((month == 4) && (date > 20)) || month > 4) && (month < 11 || ((month == 10) &&
            day < 30))) adjust -= 60;

            ourDifference = eval(gmtOffset - yourOffset);
            var half = eval(ourDifference % 60);
            ourDifference = Math.round(ourDifference / 60);
            hour = eval(hour - ourDifference);
            var m = new Array("",
            "Jan","Feb","Mar",
            "Apr","May","Jun",
            "Jul","Aug","Sept",
            "Oct","Nov","Dec");
            var leap = eval(year % 4);

            if ((half == -30) || (half == 30)) minute += 30;
            if (minute > 59) minute -= 60, hour++;
            if (minute < 0) minute += 60, hour--;
            if (hour > 23) hour -= 24, date += 1;
            if (((month == 4) || (month == 6) ||
            (month == 9) || (month == 11)) && (date==31)) date = 1, month ++;
            if (((month == 2) && (date > 28)) && (leap != 0)) date = 1, month ++;
            if ((month == 2) && (date > 29)) date = 1, month++;
            if (hour < 0) hour += 24, date --;
            if ((date == 32) && (month == 12)) month = m[1], date = 1, year++;
            if (date == 32) date = 1, month++;
            if ((date < 1) && (month == 1)) month= m[12], date = 31, year--;
            if (date < 1) date = 31, month --;
            if (((month == 4) || (month == 6) ||
            (month== 9) || (month == 11)) && (date == 31)) date = 30;
            if ((month == 2) && (date > 28)) date = 29;
            if (((month == 2) && (date > 28)) && (leap != 0)) date=28;

            for (i=1; i<13; i++) {
                    if (month == i) {
                        month = m[i]; break;
                }
            }

            var dateTime = hour;
            dateTime = ((dateTime < 10) ? "0":"") + dateTime;
            dateTime = "   " + dateTime;
            dateTime += ((minute < 10) ? ":0" : ":") + minute;
            dateTime += ((second < 10) ? ":0" : ":") + second;
            dateTime += (hour >= 12) ? " PM, " : " AM, ";
            dateTime += month + " " + date + ", " + year;

            var mainDiv = document.getElementById(clckID).innerHTML = dateTime;

            updatetime=setTimeout("checkDateTime()", 900);
            timerRunning = true;
    }

</script>

 <select onchange="timeCheck(this.value)" size="0" align="center">
                <option value="">SELECT --> COUNTRY</option>
                <option value="+480">Pacific</option> // Australia UTC offset value is 10
                <option value="+420">Central</option>
                <option value="+300">Estern</option>
                <option value="+600">Hawaii</option>
                <option value="+360">Mexico</option>
                <option value="-330">New Delhi</option>
                <option value="-480">HONG KONG</option>
                <option value="-540">TOKYO</option>
                <option value="+0">London</option>
        </select>

    <div id="zonetime"></div>
    <div id="testt"></div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:21:33+00:00Added an answer on June 10, 2026 at 12:21 am

    on setTimeout you forgot the ID

    updatetime=setTimeout(function(){checkDateTime(clckID);}, 900);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a scrollable DIV using the following: <!DOCTYPE html PUBLIC
I am trying to create a digital clock using a Thread as this seems
I am trying to emulate click events in Swing using following code: event =
I'm somewhat experienced in using JavaScript but not in dealing with jQuery and JSON.
I'm trying to create an Hello World JSF application. I have a bean with
I'm trying to follow the instructions located at How-To Create a Hello World Snap-in
i am trying to create word 2007 add-in using VS2008, and i need to
I'm trying to create a word search game (kind of like Wordament but much
I'm trying to create a function that would append two vectors together, but I
The following code is within an ajax call. I'm trying to make sure people

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.