How can I calculate the time between 2 Dates in typescript

date, typescript

Solution

Use the `getTime` method to get the time in total milliseconds since 1970-01-01, and subtract those:

var time = new Date().getTime() - new Date("2013-02-20T12:01:04.753Z").getTime();

Problem

This works in Javascript ``` new Date() - new Date("2013-02-20T12:01:04.753Z") ``` But in typescript I can't rest two new Dates ``` Date("2013-02-20T12:01:04.753Z") ``` Don't work because paremater not match date signature

Original source