In C#, typically you can use DateTime.Today
to get today's date disregarding the time component (e.g. the time component would be at midnight basically).
How do I do that using Luxom library?
I understand you can write DateTime.local()
to get a Date object with current Time included, but is there no simple way to effectively disregard the time component so that I can perform a comparison with another Date object?
I can't find any relevant information in the Luxon documentation, though I may have missed something.
In standard JS, this would do it:
new Date(new Date().setHours(0,0,0,0));
But that seems awkward?
You can
startOf('day')
to set midnight to givenDateTime
:then you can use
toJSDate()
to get the equivalent Javascript Date or other method liketoISO
,toISODate()
,toFormat()
etc to get the string representation of aDateTime
.Example:
If you need to compare Luxon objects have a look at Comparing DateTimes section of the manual.