I'm making calls to the Mailgun events API but I'm confused by the timestamp format. Timestamps show as "timestamp": 1542251497.6072
or the longer format 1542358648.178141
.
I can't find any reference to it in the documentation except their claim to follow "RFC822" specification.
How can I parse/convert these timestamps into JavaScript Date objects (GMT preferably)?
Since you already are using moment
simply use the unix
method:
moment.unix(1542251497.6072).format() // "2018-11-14T19:11:37-08:00"
moment.unix(1542358648.178141).format() // "2018-11-16T00:57:28-08:00"
Which:
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).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.