U
U
ubbe_lodbroke2020-05-10 18:47:50
JavaScript
ubbe_lodbroke, 2020-05-10 18:47:50

How to subtract the time elapsed since some date?

Maybe there is some library for counting how many minutes, hours, days have passed since a certain date?

Or prompt the algorithm calculating it.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Artem Andreev, 2020-05-10
@Pibodi

Learn to ask Google questions

D
Dima Polos, 2020-05-10
@dimovich85

timestamp know what it is? More precisely, unix time, and so - if you subtract the timestamps, and then translate the result into the desired format, then here is the algorithm.

S
shsv382, 2020-05-10
@shsv382

let startDate = new Date(1945, 5, 9);
let timeFrom = new Date() - startDate;

and then divide:
timeFrom/1000                                // секунды
timeFrom/1000/60                           // минуты
timeFrom/1000/60/60                      // часы
timeFrom/1000/60/60/24                // дни
//   ... и так далее ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question