简体   繁体   English

如何从 Luxon DateTime object 获取时间戳?

[英]How to get the timestamp from a Luxon DateTime object?

How can I get the Timestamp from a luxon dateTime object?如何从 luxon dateTime object 获取时间戳?

For example?例如?

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

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

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

This should be the equivalent to javascript's Date.getTime() function.这应该等同于 javascript 的Date.getTime() function。

The Luxon docs are surprisingly silent on this, but after some digging I finally found it: Luxon 文档对此出奇地沉默,但经过一番挖掘,我终于找到了它:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM