Andreas
Andreas

Reputation: 2193

How to get the timestamp from a Luxon DateTime object?

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.

Upvotes: 19

Views: 18166

Answers (1)

Andreas
Andreas

Reputation: 2193

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

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

Upvotes: 31

Related Questions