Skip to content
Advertisement

how to get the duration from two dates in the following format

var date2 = new Date(“04/14/2022 12:49:29”)

var date1 = new Date(“04/09/2022 06:16:49”)

I want to get the following duration (“126:32:40 “)

Advertisement

Answer

Try this solution.

Step – 1. Get the time difference between both date

JavaScript

Step – 2 Convert milliseconds to seconds

JavaScript

Step – 3 Convert seconds to Hours

JavaScript

Step – 4 Convert Seconds to miniutes

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement