How do you get seconds for a time format like "Fri, 13 Apr 2018 17:06:57 GMT"?

how to get seconds for a time format like "Fri, 13 Apr 2018 17:06:57 GMT"
I need to compare the time difference new Date (). GetTime () with the current time

Mar.03,2021

let time = new Date("Fri, 13 Apr 2018 17:06:57 GMT").getTime() - new Date().getTime()
console.log(time)

convert to Date in comparison

  

"Fri, 13 Apr 2018 17:06:57 GMT" is an instance of a Date object
getTime () can get a timestamp
you can directly subtract two Date.getTime () and get the interval milliseconds

.
Menu