这个问题在这里已有答案:
我正在使用CryptoCompare的api,here is the link
响应包含一个字段名称published_on,我试图使用moment转换为适当的日期时间格式,但它不起作用。
有人知道格式或如何将其转换为正常的日期时间格式。我正在使用javascript
这个日期是Unix时间戳。由于您正在使用时刻,请执行以下操作将其转换为日期格式
moment.unix(1551929623).format('DD/MM/YYYY')
请更改适合您的格式。
片刻文档链接https://momentjs.com/docs/#/parsing/unix-timestamp-milliseconds/
console.log(+new Date()) // unix time stamp
console.log(new Date(1551929623 * 1000 )) //unix to normal date conversion
在旁注:JS time stamp在几毫秒内,因为UNIX time stamps使用秒。 @JaromandaX感谢您的信息