I am trying to use two MM-dd-yyyy HH:mm:ss formatted dates to find the time in seconds between them. How do I go about doing this?
Use Date.parse(...) to parse the dates to create a Date object.
Date.parse(...)
Date
With .valueOf() on the created object you get the epoch (milliseconds since January 1st 1970) of this date.
.valueOf()
Do this with both dates and substract the numbers. The difference is the time in milliseconds between the dates. The rest should be clear :)
Edit:
Following discussion in comments, here is the more valid reference to Date object: http://www.ecma-international.org/ecma-262/6.0/index.html#sec-date-constructor
1.4m articles
1.4m replys
5 comments
57.0k users