Sarim  Zafar
Sarim Zafar

Reputation: 293

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!

Upvotes: 25

Views: 56586

Answers (3)

YakovL
YakovL

Reputation: 8327

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.

Upvotes: 45

James K
James K

Reputation: 3752

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

Upvotes: 7

Maxim
Maxim

Reputation: 9961

This is UNIX time in seconds:

➜  ~ irb
2.2.0 :001 > Time.at(1473912000)
 => 2016-09-15 07:00:00 +0300

Upvotes: 5

Related Questions