Reputation: 1455
I would like to check if the datetime now - datetime given = 10 minutes
Below is my code:
var duration = Date.now() - customerForgotPassword[0].createdTime.getTime()
;
and then I compare it with 10 minutes in millisecs:
var TEN_MINUTES = 10*60*1000;
if(duration > TEN_MINUTES){
//do smtg
}
But this thing always returns true because I checked TEN_MINUTES in UTC, it is equals to Thu Jan 01 1970 00:10:00
.
I would like to know how can I check if the duration is more than 10 minutes ?
Upvotes: 0
Views: 1485
Reputation: 21926
var TEN_MINUTES = 10*60*1000;
var duration = Date.now() - customerForgotPassword[0].createdTime.getTime();
if (duration > TEN_MINUTES) {
// do stuff
}
Not sure where you went wrong since it sounds like you got 90% of the way there on your own, but there you go.
Upvotes: 3