How to correctly calculate the number of minutes from a certain moment?

Mike Kharkov :

There is a start date for the process in string form:

'2020-03-02 06:49:05'

And the process completion date:

'2020-03-02 07:05:02'

Question:
What is the most correct way from the point of view of the approach - to calculate the difference (in minutes) between the start and finish of the process? (if there are any built-in methods for this in vue.js ornuxt.js, it will be very interesting to learn about them as well.)

Prakhar Londhe :

I think the best way would be to use Javascript Date object,

d1 = '2020-03-02 06:49:05'
d2 = '2020-03-02 07:05:02'

diff_in_millis = Math.abs(new Date(d1) - new Date(d2))
diff_in_minutes = diff/60000

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=220273&siteId=1