Answer the question
In order to leave comments, you need to log in
How to format seconds into readable form?
There is time in seconds, but I would like to format them depending on their number, i.e.
for example 45 is "45 seconds", 60 is "1 minute", 3601 is "1 hour 1 second". Maybe there are some modules?
Answer the question
In order to leave comments, you need to log in
let timestamp = 1598828005;
var minutes = timestamp / 60;
var hours = minutes / 60;
var days = Math.floor(hours / 24) + ' дней, ' +
Math.floor(hours % 24) + ' часов, ' +
Math.floor(minutes % 60) + ' минут, ' +
Math.floor(timestamp % 60) + ' секунд';
console.log(days);
18504 days, 22 hours, 53 minutes, 25 seconds
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question