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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:49:38+00:00 2026-05-21T21:49:38+00:00

So I already asked this question before and I received the following as an

  • 0

So I already asked this question before and I received the following as an answer which truly helps! However lets say the business opens at 9:00 AM and closes at 5:00 PM PST time (California) and they are closed on Saturday and Sunday.

How can I adjust that below?

Also keep in mind that the script below is triggering an image to show/display/hide based on the business hours. So at 9:00 AM PST time the image say’s ‘We’re Open’ and at 5:00 PM the image then goes to ‘We’re Closed’. Thanks guys I hope I have entered enough data/information for you to answer this question.

Here is a reference Fiddle.

$(window).load(function(){
  // Translate your hours to UTC, example here is using
  // Central Standard Time (-0500 UTC)

  // Opening hour in UTC is 16, Closing hour is 0 the next day
  var d      = new Date(), 
      open   = new Date(), 
      closed = new Date();

  // Statically set UTC date for open
  open.setUTCHours(16);
  open.setUTCMinutes(0);
  open.setUTCSeconds(0);
  open.setUTCMilliseconds(0);

  // Statically Set UTC date for closing
  closed.setUTCDate(d.getUTCDate()+1); // UTC time rotates back to 0, add a day
  closed.setUTCHours(0); // UTC hours is 0
  closed.setUTCMinutes(0);
  closed.setUTCSeconds(0);
  closed.setUTCMilliseconds(0);

  // Debugging
  console.log("user's date:" + d);
  console.log("store open time in user's timezone:" + open);
  console.log("store close time in user's timezone:" + closed);
  console.log(d > open); // user's time is greater than opening time
  console.log(d < closed); // is user's time less than closing time
                           // (you don't have to go home...)

  // Test for store open?
  if (d > open && d < closed) {
    setOpenStatus(true);
  } else {
    setOpenStatus(false);
  }

  function setOpenStatus(isOpen) {
    $('#opend').toggle(isOpen);
    $('#closed').toggle(!isOpen);
  }
});​

EDITED/UPDATED SCRIPT

$(window).load(function(){
  // Translate your hours to UTC, example here is using
  // Central Standard Time (-0500 UTC)

  // Opening hour in UTC is 16, Closing hour is 0 the next day
  var d      = new Date(), 
      open   = new Date(), 
      closed = new Date();

  // Statically set UTC date for open
  open.setUTCHours(16);
  open.setUTCMinutes(0);
  open.setUTCSeconds(0);
  open.setUTCMilliseconds(0);

  // Statically Set UTC date for closing
  closed.setUTCDate(d.getUTCDate()+1); // UTC time rotates back to 0, add a day
  closed.setUTCHours(0); // UTC hours is 0
  closed.setUTCMinutes(0);
  closed.setUTCSeconds(0);
  closed.setUTCMilliseconds(0);

  // Debugging
  console.log("user's date:" + d);
  console.log("store open time in user's timezone:" + open);
  console.log("store close time in user's timezone:" + closed);
  console.log(d > open); // user's time is greater than opening time
  console.log(d < closed); // is user's time less than closing time
                           // (you don't have to go home...)

  // Test for store open?
  if (d > open && d < closed) {
    setOpenStatus(true);
  }
  if (d.getDay() !== 0 && d.getDay() !== 6 && (d > open && d < closed))
  else {
    setOpenStatus(false);
  }

  function setOpenStatus(isOpen) {
    $('#opend').toggle(isOpen);
    $('#closed').toggle(!isOpen);
  }
});​
  • 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-21T21:49:38+00:00Added an answer on May 21, 2026 at 9:49 pm

    Change the bottom few lines to this, it is a little muddled at present.

    if (d.getDay() !== 0 && d.getDay() !== 6 && (d >= open && d < closed)) {
        setOpenStatus(true);
    } else {
        setOpenStatus(false);
    }
    

    So you understand the condition, it says: If it is not Sunday (d.getDay() !== 0) or Saturday (d.getDay() !== 6) and the current time is after or at the opening time (d >= open) and before the closing time (d < closed), then set the open status, otherwise (else), set closed status.

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

Sidebar

Related Questions

I know that this question had already been asked a couple of times before,
I believe lot of people already asked this question before, but i kept getting
Probably this question was already asked before, but my google-fu and SO-Search did not
I apologize if this question was asked already before but I could not find
I already asked this question before, but without any good response, my problem is
I apologise if this question has already been asked on here before but I
This question has been asked before - but with no satisfying answer at all!
This question has been asked here before . The accepted answer was probably obvious
I know this kind of questions have been asked already many times before. The
I already asked this question but at that time I tought that the refresh

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.