Disable page only durring time period
Forum rules
IMPORTANT NOTE!!
DO YOU HAVE A QUESTION OR PROBLEM AND WANT QUICK HELP?
THEN PLEASE SHARE A "DEMO" PROJECT.
PLEASE READ THE FORUM RULES BEFORE YOU POST:
http://www.wysiwygwebbuilder.com/forum/viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
IMPORTANT NOTE!!
DO YOU HAVE A QUESTION OR PROBLEM AND WANT QUICK HELP?
THEN PLEASE SHARE A "DEMO" PROJECT.
PLEASE READ THE FORUM RULES BEFORE YOU POST:
http://www.wysiwygwebbuilder.com/forum/viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
-
cwlutterloh
-

- Posts: 34
- Joined: Mon Jun 24, 2019 6:56 pm
Disable page only durring time period
I have a forms page and the user wants one of the forms to only be avaiable during morning hours. I know how to manually disable the page but can I have it automatically disable during specfic time periods?
- BaconFries
-

- Posts: 6125
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Disable page only durring time period
Yes it can be done but will require the use of a script such as javascript. The downside of this that anyone in the know could easily bypass by disabling javascript or viewing the page source. To avoid submission you would also need implement server-sided validation so to reject submissions during the set time frame.can I have it automatically disable during specfic time periods?
- jerryco
-

- Posts: 943
- Joined: Fri Mar 27, 2009 2:42 pm
- Location: Purmerend, Holland
Re: Disable page only durring time period
In case there will be no free alternatives offered in this thread, I use the paid software called MachForm and it shows this...

Info on https://machform.com.

Info on https://machform.com.
// Love is the acceptance of nothing / Account age is no guarantee of efficiency ;-) ->
Above, Beyond, and @wwonderfull! <- Genuinely helps you with a powered up site that counts! Five Times Excellence!
Above, Beyond, and @wwonderfull! <- Genuinely helps you with a powered up site that counts! Five Times Excellence!
-
cwlutterloh
-

- Posts: 34
- Joined: Mon Jun 24, 2019 6:56 pm
Re: Disable page only durring time period
This is for an internal Intranet site, my end users are not that savy. Can you elaborate on the script?BaconFries wrote: Wed Oct 22, 2025 5:11 pm Yes it can be done but will require the use of a script such as javascript. The downside of this that anyone in the know could easily bypass by disabling javascript or viewing the page source. To avoid submission you would also need implement server-sided validation so to reject submissions during the set time frame.
-
pmacdonald
-

- Posts: 39
- Joined: Wed Feb 23, 2022 7:03 pm
Re: Disable page only durring time period
if your page is PHP, the AI overload suggests this bit of code embedded at the top of the page, modify to your needs.
<?php
// Set your desired time zone. Find a list of supported time zones at php.net/manual/en/timezones.php.
date_default_timezone_set('America/New_York');
// Get the current hour in 24-hour format (0-23).
$current_hour = date('G');
// Define the time boundaries for redirection.
$early_boundary = 5; // 5am
$late_boundary = 12; // 12pm (noon)
// Check if the current time is earlier than 5am OR later than 12pm.
if ($current_hour < $early_boundary || $current_hour >= $late_boundary) {
// Specify the page to redirect to.
$redirect_url = 'https://www.example.com/unavailable.php';
// Redirect the user.
header('Location: ' . $redirect_url);
exit(); // Always exit after a header redirect.
}
// The rest of your page's code continues here if the time is within the allowed window.
// ...
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Open for Business</title>
</head>
<body>
<h1>Welcome! We are open for business.</h1>
<p>This page is only accessible between 5am and 12pm.</p>
</body>
</html>
<?php
// Set your desired time zone. Find a list of supported time zones at php.net/manual/en/timezones.php.
date_default_timezone_set('America/New_York');
// Get the current hour in 24-hour format (0-23).
$current_hour = date('G');
// Define the time boundaries for redirection.
$early_boundary = 5; // 5am
$late_boundary = 12; // 12pm (noon)
// Check if the current time is earlier than 5am OR later than 12pm.
if ($current_hour < $early_boundary || $current_hour >= $late_boundary) {
// Specify the page to redirect to.
$redirect_url = 'https://www.example.com/unavailable.php';
// Redirect the user.
header('Location: ' . $redirect_url);
exit(); // Always exit after a header redirect.
}
// The rest of your page's code continues here if the time is within the allowed window.
// ...
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Open for Business</title>
</head>
<body>
<h1>Welcome! We are open for business.</h1>
<p>This page is only accessible between 5am and 12pm.</p>
</body>
</html>
- wwonderfull
-

- Posts: 1621
- Joined: Fri Aug 21, 2020 8:27 am
- Contact:
Re: Disable page only durring time period
A browser is time conscious only when it is open and the page is current active and loaded Infront of you, and it is also bound to system time settings. Server can have its own configuration. Now that said you wanted a specific form to appear disappear on a specific time that means if you wanted to dynamically change the form on the same page you would need asynchronous form generation for it.
Think it like this you are watching the clock and it is 5 second before it becomes morning, now 5 second past the page is still the same and the form is still the same unless with time event the browser asynchronously sends the event trigger to server to load the new form but if you relied only on the server than only the page reload or POST request would change the form or else it won't change.
So, the same solution in 2 ways even if custom.
Now logically speaking you will not be able to use same <form id="contactform-or-anyform"> to be reused by other form elements because it would cause conflicts. That means you would have to have a separate form dynamically generated so both form data are separate yet both forms are found in same place in different times.
Think it like this you are watching the clock and it is 5 second before it becomes morning, now 5 second past the page is still the same and the form is still the same unless with time event the browser asynchronously sends the event trigger to server to load the new form but if you relied only on the server than only the page reload or POST request would change the form or else it won't change.
So, the same solution in 2 ways even if custom.
Now logically speaking you will not be able to use same <form id="contactform-or-anyform"> to be reused by other form elements because it would cause conflicts. That means you would have to have a separate form dynamically generated so both form data are separate yet both forms are found in same place in different times.
-
cwlutterloh
-

- Posts: 34
- Joined: Mon Jun 24, 2019 6:56 pm
Re: Disable page only durring time period
I inserted this at the begining of the page but the button click shows 404 error...
-----------------
<?php
date_default_timezone_set('America/New_York');
$current_hour = date('G');
$early_boundary = 7:30;
$late_boundary = 10;
if ($current_hour < $early_boundary || $current_hour >= $late_boundary) {
$redirect_url = 'http://URL_NA';
header('Location: ' . $redirect_url);
exit();
}
?>
------------------
-----------------
<?php
date_default_timezone_set('America/New_York');
$current_hour = date('G');
$early_boundary = 7:30;
$late_boundary = 10;
if ($current_hour < $early_boundary || $current_hour >= $late_boundary) {
$redirect_url = 'http://URL_NA';
header('Location: ' . $redirect_url);
exit();
}
?>
------------------
-
pmacdonald
-

- Posts: 39
- Joined: Wed Feb 23, 2022 7:03 pm
Re: Disable page only durring time period
I suspect the 404 error is due to the fact that the referenced page does not exist on your server:
'http://URL_NA';
Also, I don't think the existing code will work as expected if you are looking to do this based on a half hour setting, i.e. 7:30, actually I'm surprised you didn't get an error with that code.
$current_hour = date('G'); returns the hour as 0 to 23 only
additional code would be required to check for anything other than on the hour.
'http://URL_NA';
Also, I don't think the existing code will work as expected if you are looking to do this based on a half hour setting, i.e. 7:30, actually I'm surprised you didn't get an error with that code.
$current_hour = date('G'); returns the hour as 0 to 23 only
additional code would be required to check for anything other than on the hour.
- BaconFries
-

- Posts: 6125
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Disable page only durring time period
You can try the following using javascript rather that php. Add to your page with the form using Page HTML Between the <body></body> tags*. You will also need to change where it reads your form Id to match that of your Forms ID.
Note if the user/client has javascript disabled then this wont work.
Note if the user/client has javascript disabled then this wont work.
Code: Select all
<script>
const now = new Date();
const currentMinutes = now.getHours() * 60 + now.getMinutes();
const startMinutes = 7 * 60 + 30; // 7:30 AM
const endMinutes = 10 * 60; // 10:00 AM
if (currentMinutes >= startMinutes && currentMinutes < endMinutes) {
document.getElementById('your form Id').classList.add('hidden');
}
</script>-
cwlutterloh
-

- Posts: 34
- Joined: Mon Jun 24, 2019 6:56 pm
Re: Disable page only durring time period
changing the time to "7" worked.
I just put in a dummy URL for this post.
I just put in a dummy URL for this post.
- MojoBoogie
-

- Posts: 6
- Joined: Mon Sep 22, 2025 2:09 pm
Re: Disable page only durring time period
Thanks for the heads up on MachForm. We are going to use their service.
"Who Controls The Past Controls The Future, Who Controls The Present Controls The Past." Welcome to Clown 🤡 WORLD 2025...
- jerryco
-

- Posts: 943
- Joined: Fri Mar 27, 2009 2:42 pm
- Location: Purmerend, Holland
Re: Disable page only durring time period
You're welcome!
// Love is the acceptance of nothing / Account age is no guarantee of efficiency ;-) ->
Above, Beyond, and @wwonderfull! <- Genuinely helps you with a powered up site that counts! Five Times Excellence!
Above, Beyond, and @wwonderfull! <- Genuinely helps you with a powered up site that counts! Five Times Excellence!