How to get the day of the year [1-365|366] with Luxon?
Asked Answered
E

1

6

Is it possible to get the day of the year in the 1-365|366 range from a Luxon DateTime object?

I'm looking for a solution that doesn't involve computing the value. So something similar to DateTime.day, DateTime.weekNumber, DateTime.month etc. or using DateTime.toFormat() would be awesome.

Elegiac answered 2/9, 2022 at 6:41 Comment(0)
B
10

In Luxon, you can simply use ordinal:

Get the ordinal (meaning the day of the year)

Example:

console.log(luxon.DateTime.now().ordinal)
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/global/luxon.min.js"></script>
Barbbarba answered 2/9, 2022 at 6:55 Comment(1)
Thank you so much. That didnt't cross my eye while browsing the docs.Elegiac

© 2022 - 2024 — McMap. All rights reserved.