Can anyone help me with the code? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Can anyone help me with the code?

The timing event for simple offer period like in ecommerce sites.

30th Sep 2018, 2:40 PM
Top Code
Top Code - avatar
7 Antworten
+ 2
where is the code
30th Sep 2018, 3:10 PM
callum willcocks
callum willcocks - avatar
+ 1
That's great! Since your profile shows you've completed the JavaScript course, and you've clearly found the Code Playground, go ahead and show us that you've made some effort so we can troubleshoot specific issues instead of guessing what you really want.
1st Oct 2018, 3:32 AM
Janning⭐
Janning⭐ - avatar
0
i want a sample javascript code to activate a timing function
30th Sep 2018, 11:52 PM
Top Code
Top Code - avatar
0
oks
1st Oct 2018, 1:51 PM
Top Code
Top Code - avatar
0
<html> <head> </head> <body> <p id="ETA"></p> <script> var tool = new Date("January 1, 2019 00:00:00").getTime(); timer = setInterval( function() { var cur = new Date().getTime(); var dist = tool - cur; var day = Math.floor(dist / (1000 * 60 * 60 * 24)); var minute = Math.floor((dist % (1000 * 60 * 60)) / (1000 * 60)); var hour = Math.floor((dist % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var second = Math.floor((dist % (1000 * 60)) / 1000); document.getElementById("ETA").innerHTML = day + "d:" + hour + "h:" + minute + "m:" + second + "s"; if(dist < 0) { clearInterval(timer); document.getElementById("ETA").innerHTML = "Ended"; } } ) </script> </body> </html>
4th Oct 2018, 5:09 PM
Top Code
Top Code - avatar
0
i want to improve this to create a proper timing event. reusable.
4th Oct 2018, 5:09 PM
Top Code
Top Code - avatar
0
You were able to grab the time just fine. Were you looking for a start / stop mechanism or something?
5th Oct 2018, 7:30 PM
Janning⭐
Janning⭐ - avatar