Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jwt token expire times

// it uses npmjs.com/ms utility to convert various time formats to milliseconds
// milliseconds is the default format which is assumed if numeric value is not followed by valid characters
var token = jwt.sign({key_name:'key_value'}, "secret_key", {
  expiresIn: '365d'	// expires in 365 days
});

// other accepted formats
expiresIn('2 days')  // 172800000
expiresIn('1d')      // 86400000
expiresIn('10h')     // 36000000
expiresIn('2.5 hrs') // 9000000
expiresIn('2h')      // 7200000
expiresIn('1m')      // 60000
expiresIn('5s')      // 5000
expiresIn('1y')      // 31557600000
expiresIn('100')     // 100
expiresIn('-3 days') // -259200000
expiresIn('-1h')     // -3600000
expiresIn('-200')    // -200
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jwt #token #expire #times
ADD COMMENT
Topic
Name
1+2 =