Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 860
Andreas Avatar asked Dec 03 '25 05:12

Andreas


1 Answers

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

date.toMillis(); 
// or 
date.valueOf(); 
like image 90
Andreas Avatar answered Dec 05 '25 18:12

Andreas