首页 > 解决方案 > 如何从 Luxon DateTime 对象中获取时间戳?

问题描述

如何从 luxon dateTime 对象获取时间戳?

例如?

const { DateTime } = require("luxon");

date = DateTime.now().setZone('utc');
date.endOf('day);

console.log(date.???) // should give something like 1629399474922

这应该相当于javascript的Date.getTime()功能。

标签: javascriptluxon

解决方案


Luxon 文档对此出奇地沉默,但经过一番挖掘,我终于找到了它:


date.toMillis(); 
// or 
date.valueOf(); 

推荐阅读