I Need Countdown Timer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

I Need Countdown Timer

This countdown show to me my coming up next birthday, in months, weeks hr min sc etc. I want a counter timer that tells me how much time has passed from my birthday to the next birthday... When the next birthday comes, the countdown will automatically start from zero and continue until the next birthday. https://code.sololearn.com/WaKUPUc4By5Q/?ref=app

18th Jul 2022, 12:56 PM
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫 - avatar
5 Answers
+ 7
// You need to change the the distance to: var distance = now - countDownDate;
18th Jul 2022, 1:07 PM
JaScript
JaScript - avatar
+ 4
I think more easier is to write it with a few new html tags and some additional css.
18th Jul 2022, 4:18 PM
JaScript
JaScript - avatar
+ 2
#JaScript thanks... How to i add a css .class or id in <style> </style> ? Who added in jascript?
18th Jul 2022, 1:16 PM
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫 - avatar
+ 2
https://code.sololearn.com/WaKUPUc4By5Q/?ref=app Please check again i added a comment.
18th Jul 2022, 1:19 PM
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫 - avatar
+ 2
After you define distance you need a check to see if the date has already passed. Here's a very crude example: if (distance<0) countDownDate = new Date("June 12 "+(year+1)+", 12:00:00").getTime(); Note: If you weren't really born at noon and just want to count down to the day of your birthday, you should use 00:00 for the time.
18th Jul 2022, 1:22 PM
Steve
Steve - avatar