Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decoding the expiry date of a JavaScript Web Token (JWT)?

I am unable to understand the expiry date format of the JWT embedded in my application.

For example: 1473912000

What does this translate to? 1473912000 ms, some x date? Any help will be appreciated!

like image 795
Sarim Zafar Avatar asked Sep 14 '16 20:09

Sarim Zafar


3 Answers

Like James has pointed out:

The number is the number of seconds since Jan 1 1970.

This is converted into the Date object in a quite straight-forward way (the *1000 part is here because in JS main time unit is millisecond):

const expiryDate = new Date(1473912000*1000);

Then you can use any Date method you please.

Likewise, in Ruby you can use Time.at(1473912000) to create a new Time instance like Maxim has shown.

like image 164
YakovL Avatar answered Nov 10 '22 15:11

YakovL


The number is the number of seconds since Jan 1 1970. It is commonly used on unix systems to represent time. Your time is 2016-09-15 04:00 (UTC)

To convert you can try a web based system http://www.unixtimestamp.com/index.php

like image 6
James K Avatar answered Nov 10 '22 16:11

James K


This is UNIX time in seconds:

➜  ~ irb
2.2.0 :001 > Time.at(1473912000)
 => 2016-09-15 07:00:00 +0300
like image 4
Maxim Avatar answered Nov 10 '22 14:11

Maxim