javascript check if date object is at least 5 minutes old (nodeJS)

Viewed 11364

How to compare a date object in javascript to check if the object is at least 5 minutes old? I tried:

//current date
var date = new Date();
//data from database
console.log("db: " + data_from_database)
console.log("current date: " + date)

//how to check if "data_from_database is at least 5 minutes old?

db: Sun Jul 16 2017 23:59:59 GMT+0200 (CEST)

current date: Sun Jul 16 2017 14:12:43 GMT+0200 (CEST)

How to perform the check the simplest way without creating tons of new objects?

2 Answers
Related