jeudi 26 février 2015

How to create JWT exp style date in Javascript

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?


Aucun commentaire:

Enregistrer un commentaire