How to create JWT exp style date in Javascript

javascript, jwt, node.js, oauth-2.0

Solution

How about:

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

Problem

I'll like to create JWT exp claim style date in Javascript. My app jwt claim returns an expiry date of 1424984529. I'm doing a test for token expiration using this: ``` if(jwt.exp < Date.now())) { // do something } ``` As at writing Date.now() gives me 1424941329632 and jwt.exp gives 1424984529. Obviously, my test will always return true. So my question is, how do I mimic jwt-style exp date in Javascript?

Original source