18

How can I get the Timestamp from a 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.

1 Answer 1

29

The Luxon docs are surprisingly silent on this, but after some digging I finally found it:

date.toMillis(); 
// or 
date.valueOf(); 
1
  • 2
    You can also do +date Commented Aug 25, 2021 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.