Obviously this question has multiple parts : one to get a countdown and one to alternate which to display. I want a countdown to the weekend (Saturday 00:00) and on the weekend it will display a countdown to the end of the weekend (Monday 00:00)
So first the countdown : the way I can see is to go on a countdown site, and use and then it will be there, the only problem is this wouldn't fit with the background and you'd have to scroll. So you must use another method.
Secondly the alternation : I don't have many ideas for this but I have to think of something or this is off topic. So if I want this to change twice. I could make the countdown a variable (x) and then you would test if x is 0 then add one to y and when it is an odd number, display the 5 day countdown (432000 seconds) then when it is an even number then display the 2 day countdown (172800 seconds) So here is my (probably failed) attempt :
if x=0 {
if y=1 {
var z=432000
}
else {
var z=172000
}
}
I do not know if this is right but I hope you appreciate my attempt. Thank you in advance!
So if you're trying to write a little web app that does what you ask, then really it doesn't require you to use a third party timer. What you really want is the
Date
object. You can then use this to detect the current time and day of the week, and use that to figure out a) which timer you want, and b) how long until the timer ends.Just a word of warning, I haven't tested any of this. All you need to do now is put all this code in a setInterval. To do that, you first have to wrap all of the above code in a function definition (which we can call the
getTime
function).