Mailgun 事件 API 时间戳

Mailgun events API timestamp

我正在调用 Mailgun 事件 API,但我对时间戳格式感到困惑。时间戳显示为 "timestamp": 1542251497.6072 或更长的格式 1542358648.178141.

除了他们声称遵循 "RFC822" 规范外,我在文档中找不到任何参考。

如何将这些时间戳 parse/convert 转换为 JavaScript 日期对象(最好是 GMT)?

因为您已经在使用 moment,只需使用 unix 方法:

moment.unix(1542251497.6072).format()    // "2018-11-14T19:11:37-08:00"
moment.unix(1542358648.178141).format()  // "2018-11-16T00:57:28-08:00"

其中:

Similar to new Date(Number), you can create a moment by passing an integer value representing the number of milliseconds since the Unix Epoch (Jan 1 1970 12AM UTC).