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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:49:28+00:00 2026-06-17T05:49:28+00:00

I want to show on our site when the chat is available. The problem

  • 0

I want to show on our site when the chat is available. The problem is that it won’t be open in the weekends. How do I exclude them? Can it be done?

<html>
<body>
<script type="text/javascript">
function chatonoff(){
var now = new Date();
var hour = now.getHours();

if (hour >=9 && hour <=18)
{
document.getElementById("chat").src = "/bilder/butik/chat-open.png";
}
}
</script>
<img id="chat" src="/bilder/butik/chat.png" onload="chatonoff()">

</body>
</html>
  • 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-17T05:49:30+00:00Added an answer on June 17, 2026 at 5:49 am

    You could do like this

    function chatonoff(){
        var now = new Date();
        var hour = now.getHours();
        var day = now.getDay();
    
        //Check if weekend : in this case, I assume that saturday == 6 and Sunday = 0
        //It depends on your location / timezone
        if(day != 6 && day != 0)
        {
            if (hour >=9 && hour <=18)
            {
                document.getElementById("chat").src = "/bilder/butik/chat-open.png";
            }
        }
    }
    

    EDIT

    About excluding hollidays :

    You should create an array with all the off dates. Then, check if the curent day is present in the array

      var offDaysListArray = ['2013-01-01','2013-01-02'];
    
      var now = new Date();
      var y = now .getFullYear();
      var d = (now .getDate() < 10) ? '0'+now .getDate() : now .getDate();
      var m = ((now .getMonth()+1) < 10) ? '0'+(now .getMonth()+1) : (now .getMonth()+1);
    
      //Check if it is a closed day
      if(offDaysListArray.indexOf(y + '-' + m + '-' + d) != -1)    
          return false; //It is a close day
    

    Be carefull with indexOf, old browser like IE8 doesn’t implement this function. Check Why doesn't indexOf work on an array IE8?

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

Sidebar

Related Questions

Our site has some very complicated form controls that are submitted and then show
We may want show Date Today or Other things in our site on top
I'm using Drupal 7 and Views module in my site. And want show number
My boss wants our site to show an alert if a customer tries to
Every time a user registers to our site we need to show a NDA
I need to show some basic stats on the front page of our site
Suppose that we have a website. We want to show a specified part of
Throughout our site there's a common model, let's say Video, that has a number
We want to show some JSON to a user who is testing our application.
A simple scenario: I want to delete a pagelayout that is out-dated from our

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.