countdowntimer - Countdown Timer JS -
Hello, I have a JavaScript countdown timer, without entering the day. Okay, I want to add it to the right formula for the day's report. This is my js code: (sorry for my english, i use google translate)
var tick = function init) {if (init == undefined) {init = False; } Var current_time = new date (); Current_time = current_time.valueOf (); If (current_time & gt; target_time) {var time = new date (); Target_time = new date (time.guulular (), time.get (), time.getrate ()); Target_time = target_time.valueOf () + 1000 * 60 * 60 * 24 * 45; } Var time_diff = Math.floor ((target_time - current_time) / 1000); // warning (time_diff); Var second_2 = time_diff% 10; Time_Diff = Math Floor (Time_dif / 10); Var second_1 = time_diff% 6; Time_diff = Math.flur (time_delay/6); Var min_2 = time_diff% 10; Time_Diff = Math Floor (Time_dif / 10); Var min_1 = time_diff% 6; Time_diff = Math.flur (time_delay/6); Var hour_2 = Time_diff% 10; Time_Diff = Math Floor (Time_dif / 10); Var hour_1 = time_diff% 6; Time_diff = Math.flur (time_delay/6); Var day_2 = Math.flur (Time_Diff / 24); Var day_1 = time_diff% 24; Set_slide ('span.secondPlay', second_2); If ((second_2 == 9) || init) {set_slide ('span.second6Play', second_1); If ((second_1 ==5) || init) {set_slide ('span.minutePlay', min_2); If ((min_2 == 9) || init) {set_slide ('span.minute6Play', min_1); If ((min_1 == 5) || init) {set_slide ('span.hourPlay', hour_2); If ((hour_2 == 9) || init) {set_slide ('span.hour2Play', hour_1); If ((hour_1 == 1) || init) {set_slide ('span.dayPlay', day_2); If ((day_2 == 9) || init) {set_slide ('span.day1play', day_1);}}}}}}}} tik (true); Set interval (tick, 1000);
And this is my html
& lt; Div class = "timer" & gt; & Lt; Div class = "container" style = 'padding-top: 0px;' & Gt; & Lt; Div class = "day" & gt; & Lt; Span class = "flip day 1 play" & gt; & Lt; / Span & gt; & Lt; Span class = "flip de-play" & gt; & Lt; / Span & gt; & Lt; Them & gt; Dagen & lt; / Them & gt; & Lt; / Div & gt; & Lt; Div class = "hour" & gt; & Lt; Span class = "flip hour 2 plays" & gt; & Lt; / Span & gt; & Lt; Span class = "flip bell ran" & gt; & Lt; / Span & gt; & Lt; Them & gt; Часов & lt; / Them & gt; & Lt; / Div & gt; & Lt; Div class = "minute" & gt; & Lt; Span class = "flip min 6 play" & gt; & Lt; / Span & gt; & Lt; Span class = "flip minute play" & gt; & Lt; / Span & gt; & Lt; Them & gt; Минут & lt; / Them & gt; & Lt; / Div & gt; & Lt; Div class = "seconds" & gt; & Lt; Span class = "flip seconds 6 play" & gt; & Lt; / Span & gt; & Lt; Span class = "flip secondplay" & gt; & Lt; / Span & gt; & Lt; Them & gt; Секунд & lt; / Them & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;
My problem is well that I can not write the correct formula for displaying the day. My formula is wrong
var day_2 = Math.floor (time_diff / 24); Var day_1 = time_diff% 24;
How can I add the day's functionality to this JS code, I see many countdown timers but I want to thank you.
To get the number of days from the timetable in seconds, you can use it:
day_2 = (Time_diff / (60 * 60 * 24))% 10; Day_1 = Math.floor ((time_dk / (60 * 60 * 24) / 10);
Put it here:
var time_diff = Math.floor ((target_time - current_time) / 1000); Day_2 = (Time_diff / (60 * 60 * 24))% 10; Day_1 = Math.floor ((time_dk / (60 * 60 * 24) / 10); Var second_2 = time_diff% 10; Time_Diff = Math Floor (Time_dif / 10);
Comments
Post a Comment