if(err.name === 'TokenExpiredError') {
const payload = jwt.verify(token, SECRET, {ignoreExpiration: true} );
// your code
}
private tokenExpired(token: string) {
const expiry = (JSON.parse(atob(token.split('.')[1]))).exp;
return (Math.floor((new Date).getTime() / 1000)) >= expiry;
}
ngOnInit() {
if (this.tokenExpired(token)) {
// token expired
} else {
// token valid
}
}
var current_time = Date.now() / 1000;
if ( jwt.exp < current_time) {
/* expired */
}