Question: how to check whether my token is expired or not?

```
var token = jwt.sign(user,app.get('superSecret'),{
    expiresIn : 2
});

```

Answer: 
I assume you are using the jsonwebtoken package that is [documented here](https://github.com/auth0/node-jsonwebtoken#tokenexpirederror "documented here")

If that is the case, have a look at the `jwt.verify` method:

```
jwt.verify(token, 'shhhhh', function(err, decoded) {
  if (err) {
    /*
      err = {
        name: 'TokenExpiredError',
        message: 'jwt expired',
        expiredAt: 1408621000
      }
    */
  }
});

```

In short words: Check the error of that method. If it is the TokenExpiredError then, guess what... the token is expired.
```
var isExpiredToken = false;
var seconds = 1000;
var d = new Date();
var t= d.getTime();

if (decoded.exp < Math.round(t / seconds)) {
  // code...
  isExpiredToken = true;
}

```

Source:
<https://www.w3schools.com/jsref/jsref_gettime.asp>