【问题标题】:How to get the timestamp from a Luxon DateTime object?如何从 Luxon DateTime 对象中获取时间戳?
【发布时间】:2021-10-21 11:37:23
【问题描述】:

如何从 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() 函数。

【问题讨论】:

    标签: javascript luxon


    【解决方案1】:

    Luxon 文档对此出奇地沉默,但在 some digging 之后我终于找到了它:

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

    【讨论】:

    • 你也可以+date
    猜你喜欢
    • 1970-01-01
    • 2014-10-25
    • 2020-06-08
    • 2016-10-03
    • 2023-03-16
    • 2021-06-07
    • 1970-01-01
    • 2017-09-16
    • 2021-04-22
    相关资源
    最近更新 更多