Search code examples
javascriptdateiso8601

Check if ISO 8601 date older than 5 minutes


I'm a little surprised. haven't found any answers on google (maybe I'm searching wrong?)

My question: How can i check if this 2018-05-21T00:04:01.891Z date older than 5 minutes?


Solution

  • Subtract the date from the current date, and check if the difference (which is in milliseconds) is greater than 5 * 60 * 1000, which is 5 minutes in ms.

    (new Date() - new Date("2018-05-21T00:04:01.891Z")) > 5 * 60 * 1000