Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140161

How to subtract one new Date with another?

$
0
0

I need a subtraction between dates:

new Date() - new Date();

Or to do that with string dates:

finishTime: "2019-10-29T01:30:35.423"
startTime: "2019-10-23T09:17:17.423"

How to do that properly in JS?

I have tried this:

const s = new Date(item.finishTime).getDate();
const f = new Date(item.startTime).getDate();
const d = new Date(f - s);

It gives me difference: Thu Jan 01 1970 03:59:59 GMT+0400 Standard Time)


Viewing all articles
Browse latest Browse all 140161

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>