Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Luxon DateTime to start of day (reset time)

I have trawled the docs, but cannot find a a helper to reset the time of a Luxon DateTime.

I can start with a standard date:

export const getDateOnly = (date: Date = new Date()) =>  new Date(
  date.getFullYear(),
  date.getMonth(),
  date.getDate()
)

export const today = () => DateTime.fromJSDate(getDateOnly());

but this seems like a common scenario and I might have just missed it?

like image 778
jenson-button-event Avatar asked Nov 16 '25 02:11

jenson-button-event


1 Answers

Reposting as answer for future reference.

https://moment.github.io/luxon/api-docs/index.html#datetimestartof

With example:

export const today = () => DateTime.now().startOf('day');
like image 139
Spencer5051 Avatar answered Nov 18 '25 17:11

Spencer5051



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!