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 6376691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:46:39+00:00 2026-05-25T01:46:39+00:00

In following code document.getElementById(clock) is null , How can it be solved? var interval

  • 0

In following code document.getElementById("clock") is null, How can it be solved?

    var interval = self.setInterval("clock()", 1000);
    function clock() {
        var date = new Date();
        var hourOffset = 3;
        date.setUTCHours(date.getUTCHours(), date.getUTCMinutes());
        var time = date.getTime();
        date.setUTCFullYear(date.getUTCFullYear(), 2, 22);
        var dstStart = date.getTime();
        date.setUTCFullYear(date.getUTCFullYear(), 8, 22);
        var dstEnd = date.getTime();
        if(time > dstStart && time < dstEnd)
            hourOffset = 4;
        date.setUTCHours(date.getUTCHours() + hourOffset, date.getUTCMinutes() + 30);
        var output = date.getUTCHours() + ":" + date.getUTCMinutes() + ":" + date.getUTCSeconds();
        document.getElementById("clock").innerHTML = output;
    }
  • 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-05-25T01:46:40+00:00Added an answer on May 25, 2026 at 1:46 am

    First of all, you need an element with id “clock”, secondly, you need to execute that code after the DOM is ready, not before because otherwise JS won’t find the element.

    In other words… add:

    <div id='clock'></div>
    

    And paste that javascript code before the </body> in your document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i can reference link with specific id with following code $(document).ready(function(){ $(a#example_link_id).click(function(event){ var url
I have the following code: var tempIdx = document.getElementById('cityBuild').selectedIndex; var tempBuilding = document.getElementById('cityBuild').options[tempIdx].value; //
So I have the following JavaScript code: <script type=text/javascript> function clearRadioButtons() { document.getElementById(radiobutton1).checked=; //etc
I have the following code: $(document).ready(function() { var id = 'cbx'; var idPrefix =
Should the following code not work? $('.elastica').click(function(){ document.getElementById('bigimage').attr('src')= $(this).attr('src'); }); It doesn't change a
I have the following code $(document).ready(function() { $('a#slick-toggle').click(function() { $('#slickbox0').toggle(400); return false; }); });
I have the following code: $(document).ready(function(){ $(.yearInner).hide(); $(.year, this).hover( function () { $(.yearInner, this).slideToggle();
I have the following code: $(document).ready(function() { // Manage sidebar category display jQuery(#categories >
Consider the following code: $(.lcontainer a).click(function () { var current = $(this); var name
I have the following code snippet in my page. <script type=text/javascript> function expandCollapse(id){ var

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.