How to create JWT erase date in Javascript

I like to create JWT exp style style in Javascript. My jwt expression returns the expiration date of 1424984529. I am doing a test to expire a token using this:

if(jwt.exp < Date.now())) {
  // do something
}

As when writing Date.now () gives me 1424941329632, and jwt.exp gives me 1424984529. Obviously, my test will always return true.

So my question is: how do I imitate jwt-style exp date in Javascript?

+4
source share
1 answer

What about:

if (jwt.exp < Date.now() / 1000) {
  // do something
}
+10
source

All Articles