javascript - Mailgun events API timestamp
问题描述
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)?
解决方案
由于您已经在使用,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"
哪个:
与 new Date(Number) 类似,您可以通过传递一个表示自 Unix 纪元(1970 年 1 月 1 日 12AM UTC)以来的毫秒数的整数值来创建时刻。
推荐阅读
- python-3.x - 为什么文件内容不显示
- javascript - JSP Checkbox 多条信息
- mysql - 如何防止用户看到 MySQL 中的数据库和表列表?
- node.js - 为什么我不能从其他容器访问 docker 容器中的 postgres
- time-series - 为每个案例结转数据
- postgresql - 使用 current_date 时,Postgres SQL 查询运行速度非常慢
- netsuite - 使用 SuiteScript 2.0 获取应用记录的实际记录
- java - 具有子查询的 JPA 规范存在失败 SQL Server 语法
- excel - Excel - 如何将范围内的所有项目列出到列中?
- unit-testing - 在 Golang 中对 GraphQL 进行单元测试