I’m trying to create a landing page that will only be displayed according to the hours I defined .
For example:
The image of we are open will be displayed from 8am to 2pm
The picture of we closed will be displayed from 2pm to 8am
who can help me solve this file?
Put this in a on scene load (not the head) Also you would need to test…
//The image of we are open will be displayed from 8am to 2pm
///The picture of we closed will be displayed from 2pm to 8am
stopTime = 14
startTime = 08
var timerDisplay = document.getElementById('open');
var fairBanner = document.getElementById('close');
timerDisplay.style.display = 'none';
fairBanner.style.display = "none";
function updateClocks() {
//var nowTime = new Date("2017-05-15T13:01:00+01:00" ).getHours(); //-- TEST time
var nowTime = new Date().getHours(); //--0 to 23, representing the hour
nowTime < stopTime && nowTime >= startTime ? (
timerDisplay.style.display = 'block',
fairBanner.style.display = "none"
) : (
timerDisplay.style.display = 'none',
fairBanner.style.display = "block"
)
window.setTimeout(updateClocks, 1000);
}
window.setTimeout(updateClocks, 1000);
I do a test on the hours of my time, and still the hours do not work for me accurately.
What should I do to make it work exactly by am / pm?
Open - 8:00 pm.
Stop - 8:30 pm.
the vars just need to be two digit numbers which represent hours.
i.e
stopTime = 08
startTime = 09
you do not use them when testing.
var nowTime = new Date( ).getHours //–0 to 23, representing the hour
new Date( )
Will get the current date registered on the client computer…
.getHours part will parse the hours of that date
If you want to set a specific date either in the published page or just for testing then you need to set a date /time.
This sort of date code and time allows you to do tests without waiting. When testing you only need to change the components of the date/time code that you are bothered about.
I’m just trying to figure out what to do to make it appear not only in round hours.
stopTime = 08
startTime = 09
For example - ( startTime = 08:00 stopTime = 08:30
Another question:
Can I set a number of hours …? I mean that … only in those hours that I set will display the closed image.
For example -
14:00 14:30
17:30 16:30
18:00 19:00
I would like to help you further but you are not answering the questions I am asking or showing me you understand what I am explaining. You are just marching on with more questions.
I do not see any point in just putting up code in response to more questions like this
You need to understand how the date/time API works. That is the first problem we need to solve…
Mark You’re right!
I’m always looking to focus on solving a problem less than understanding it (:
Sorry but I did not notice this is a questions.
So… this is what I get