admin管理员组文章数量:1321070
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 puting the value. So something similar to DateTime.day
, DateTime.weekNumber
, DateTime.month
etc. or using DateTime.toFormat()
would be awesome.
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 puting the value. So something similar to DateTime.day
, DateTime.weekNumber
, DateTime.month
etc. or using DateTime.toFormat()
would be awesome.
2 Answers
Reset to default 10In 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/npm/[email protected]/build/global/luxon.min.js"></script>
In a format string, use "o"
(ordinal) for the day of the year:
console.log(luxon.DateTime.now().toFormat("o"));
<script src="https://cdn.jsdelivr/npm/[email protected]/build/global/luxon.js"></script>
本文标签: javascriptHow to get the day of the year 1365366 with LuxonStack Overflow
版权声明:本文标题:javascript - How to get the day of the year [1-365|366] with Luxon? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742092244a2420336.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论