I am creating a timer in JS. I am getting the time left until the date and storing it in a variable called distance. I am then getting the time left in days, hours, minutes and seconds. I would like to know if there is a way to also get the deciseconds (second/10)
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
Just continue according to the same logic:
var decis = Math.floor((distance % 1000) / 100);
So this will be a one-digit integer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.