【发布时间】:2019-01-27 04:24:55
【问题描述】:
console.log('DEBUG::+jwtDecode(token).exp', +jwtDecode(token).exp); //1534820211
console.log('DEBUG::try', new Date(+jwtDecode(token).exp).toISOString());
//DEBUG::try 1970-01-18T18:20:20.211Z
我有一个价值为1534820211 的令牌,当我尝试使用toISOString() 转换它时,它给了我一年1970-01-18T18:20:20.211Z。
但是当我在jwt.io 解码相同的令牌,并将鼠标悬停在exp 上时,它显示2018-08-21....,这是巨大的差异。我还尝试将jwtDecode(token).exp 传递给moment 并使用格式,仍然在1970xxxx 中返回我的日期时间。
moment(jwtDecode(token).exp).format();
【问题讨论】:
标签: javascript date jwt momentjs