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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:49:31+00:00 2026-06-14T16:49:31+00:00

Good morning, I created a function that gets all the USA timezone times and

  • 0

Good morning, I created a function that gets all the USA timezone times and returns them to me highlighting which timezone you are in. The issue is I want it to run every minute. When I use the setInterval function I keep getting a javascript error saying ‘invalid argument’. Here is my code in jsFiddle http://jsfiddle.net/Qg2eL/

// Timezone
var arrTime = new Array();
var arrZone = new Array("ET","CT","MT","PT");

var getTimeZones = setInterval(timeZone(),60000);

function timeZone(){
    var location = 0;
    var current_date = new Date();
    var offset = parseInt(-current_date.getTimezoneOffset() / 60);

    switch(offset){
        case -5:
            location = 0;
            break;
        case -6:
            location = 1;
            break;
        case -7:
            location = 2;
            break;
        case -8:
            location = 3;
            break;
    }

    arrTime.length = 0;
    for(var x=5; x<9; x++){
        var current_date = new Date();
        var utc_hour = current_date.getUTCHours() - x;
        var utc_minutes = current_date.getUTCMinutes().toString();

        var dd = "AM";
        if(utc_hour >= 12){
            utc_hour = utc_hour - 12;
            dd = "PM";
        }
        if(utc_hour == 0){ utc_hour = 12; }
        utc_minutes = utc_minutes<10?"0"+utc_minutes:utc_minutes;

        var formattedTime = utc_hour+":"+utc_minutes+" "+dd;

        arrTime.push(formattedTime);
    }

    var strHTML = "";
    strHTML += "<ul>";
    for(var x=0; x<arrTime.length; x++){
        strHTML += "<li>"+arrZone[x]+": "+arrTime[x]+"</li>";
    }
    strHTML += "</ul>";

    $('.timezoneHolder').html(strHTML);
    $('.timezoneHolder ul li:nth-child('+(location+1)+')').css({
        "color":"lime",
        "font-weight":"bold"
    });
}
  • 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-14T16:49:33+00:00Added an answer on June 14, 2026 at 4:49 pm

    Very common mistake is that you’re not passing the function to be executed but actually calling it in this line:

    var getTimeZones = setInterval(timeZone(),60000);

    Rather:

    var getTimeZones = setInterval(timeZone,60000);

    PS. tested in Chrome and IE. and no invalid argument popped up.

    Edit: The reason you’re not seeing it pop up after making your change is because it will only be executed after 60 seconds, so you should just call the function after your setInterval and will be executed every 60 seconds afterwards.

    var getTimeZones = setInterval(timeZone,60000);
    timeZone();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good Morning, I have created an ASP.NET 3.5 webform that allows users to search
Good morning all, I've got an association that I'm working on, and for some
Good morning all, i want to create an event in MySQL that will UPDATE
Good morning, I've successfully created a little app that registers itself under a custom
Good Morning All. I've been struggling with this issue for a while now, and
Hi all and good morning! The issue I'm having today is with IE7's rendering
Good Morning All, I have created a different background and a few other images
Good morning... I have created a custom post type called Testimonials. To display them,
Good morning, I am currently developing a java web application that exposes a web
Good morning. I've been having this issue for some days and have been lokking

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.