0
How to create an endless countdown timer loop, made of days hours minutes and seconds?
15 odpowiedzi
+ 5
@Sam Sung wrote:
<< i shall try them and get back to yu with the results. Later i can post the script that i have done since its different from the one you have made. >>
It sounds like if you're lying, and just wait for someone write it for you ^^
You're lucky, your topic has inspired me, and I've done my version, even if you don't deserve it :P
https://code.sololearn.com/Wt7K7MGvgG1I/#js ( some animations, and basic responsive design inside )
+ 4
First you need to know which year it is. For example, your code should result 2017 for now.
Then find the date of 31 December of this year in milliseconds. It is the end of this year. Consider the time 23:59:59:999.
Calculate the difference between now and the end of this year.
Finally show the result. Be aware that the result is in milliseconds. You need to do some calculations to find number of days, hours, minutes and seconds.
As solo learn is a learning app, I don't share code here. But if you stuck, there is one in my profile.
+ 3
What do you mean by "endless"?
+ 3
@Sam Sung wrote: "i tried different if and for combination and couldn't get it right because i couldn't get where it should be placed in the function."
In this case, post your code attempt, and you'll get help to get it right ;)
Anyway, it's no fair to delete the initial rules from your question, and post a code that give the impress you've asked for Christmass countdown instead of new year one ;P
+ 3
Your condition is wrong, at least:
'remTime %=0' is equivalent to doing a division by zero. So, JS don't raise an error, but the returned value is NaN, what's equivalent to false ^^
+ 3
Probably... but I don't know: you're giving only extract of code without context, and modifying your asking each time you get an answer, saying that you already have found yourself ^^
+ 1
Make an if state ments if blah blah blah then it starts the count down if 364:24:60:60 ten subtract one every second and so on if 364:24:60:0 then sub one from the second 60 and make an if statement if 0:0:0:0 then restart
the program or use if else statements
+ 1
Thank you jack and Mohammad for the answers, i shall try them and get back to you with the results. Later i can post the script that i have done since its different from the one you have made.
+ 1
Can you check another question i have posted about geolocation the code is there too in my codes.. On that question i have no clue how to do it.. So i wish you could help. And thank you all friends you rock
0
For example a new year countdown. when it hitd the new year the timer becomes 0-0-0-0.
I want it to start a new countdown immediately for the next new year
0
Visph, first of all thanks for the answer, i haven't checked your code yet and I'll public mine in the next hour, the problem is that i have it on my computer and i use solo learn on my phone
Second of all, i came here to learn and my goal is to understand because i tried different if and for combination and couldn't get it right because i couldn't get where it should be placed in the function.
Now if you look at my code and change the date to a one that has passed for example 27 of February, my countdown starts counting in negative numbers
0
Fellas the code link is in the description
0
Visph well coming from Russia Christmas here is on the 7th of January not on the 25th plus many people don't celebrate Christmas so i thought it will be legit to ask about the new year instead hehe
But what is important here is that I'm not trying to steal ideas so back to your first point hehe.. But what can you comment on my code.. How to get it working??
0
Visph the code
if (remTime %= 0)
{var eventDate = eventDate.getTime(now.getfullYear(),11,25);}
else
{var eventDate = eventDate.getTime(now.getfullYear()+1,11,25);}
As you can see i posted the working code, but in my attempts i used now. Getfullyear instead of writing 2017... I thought this might work. It for some reason it's not...
0
Visph i figured this out the moment i posted it lmao... That's abit embarrassing.. But does the condition look right if i change the remtime is not equal to zero?