here is my question:
I’ve a website that works only during the night (after 21:00 until 24:00)
I have a button that says “Enter”, but i want that button to alert() a message such as 'The website is not available yet'.
But to do so it must check the time so in pseudocode:
if (time is less more than 21:00 and less than 24:00) {
return true;
} else {
alert('the website is not available yet');
e.preventDefault;
return false;
}
But I don’t understand how I can do that in terms time difference, in any day,
any hint?
thank you guys!
will return current hour (
13when I am writing this at 13:42). However this solution has several drawbacks:getUTCHours()Thus consider fetching time from the server when rendering the page and repeating the test on the server side when user enters (to make sure the check was not bypassed).