Form question - Form or content available regarding the time of day

Hi all.

Is it possible to do the following with a form:
I need to build some kind of form that is visible on a website from, Lets say, monday 12.00 am and disappears after thursday 6.00 Pm. every week.

Anybody?

Regards,
Rob

Hello @Robboxxx do you need for example one button to the form that is visible at that scheduled time only? Or do you want like @Wam show the form itself visible at that scheduled time?

Hi Pealco

Both could be an option. I’m looking for an easy sollution.

Regards,
Rob

There you go,

Try if is this what you want, sorry for the design, but i’s a simple style to see if is this you want.

Then for you to try, you need to change the clock of your computer, if you need this to respect the server site, let me know.

NOTE: I edited the title of the topic, so more people could benefit from your question.

Yes that is what i’m looking for. It would work fine.

Regards,
Rob

So it is simple as:

1st - Add classes to items you want to show or hide in that time: lets call them:
.whenopened - for items you want to show when site is opened
.whenclosed - for items you want to show when site is closed

Then go to page Page settings, and in Add Code c/p the following code (assuming you want a 10-18 opening hours):

<script>
document.addEventListener("DOMContentLoaded", function() {
	var d = new Date();
if(d.getHours() >= 10 && d.getHours() <= 18 ){
    $(".whenopened").show();
    $(".whenclosed").hide();
}
else {  
     $(".whenclosed").show();
    $(".whenopened").hide();
}
});
</script>

Just change 10 for the hour you want to open, and change 18 for the hour you want to close.

Hope it helps you…

I thank you. Just one question: is it possible to do it over several days? Lets say from monday 12.00 til thursday 18.00 hours.

You haven’t mentioned what the use-case is but just remember two things

  1. Browser Javascript is not a secure mechanism (ie the user can potentialy change it)
  2. Across the world there are timezones, so local times vs server could vary for each visitor.

Hello @pauland that’s exactly because your second point I ask the above!
But even so, if you uses a shared server the local time of the server will be different, so you always have to use timezones. And I know some cases, that the provider change the hosting of the data, and one day they are in on country server and in the other they change for another one.

I professionally use this method in one thing, I have a client: hotel, that when you enter in the wifi it redirects to a landing page, and in the tab of the restaurant I have a banner with “Closed” and when is open the client can order the food to the room by a form, so that’s when I used this method.

No harm in emphasising a point and making it in perhaps another way.

Hi all

Let me explain: it is a website for a caving organisation. Once a week a cave is open for members. Due to covid19 our members have to register in advance in stead of just show up. The Registration starts on monday 12.00 ‘o clock and ends on thursday 18.00 ‘o clock. Al the members live in a 50 km radius and the hosting server is in the same timezone so that won’t be a problem. The script posted
would work if I could use it for the days mentioned.