admin 管理员组文章数量: 1086019
moment.js deprecated according to its documentation, So I used Luxon in my react project. I need to format the date like DD'MM yyyy, Luxon does not accept this format while MomentJs successfully did it. If you guys find any way to handle this in Luxon please answer:
MomentJS
moment('06/24/2020').format('DD\'MM yyyy') // output is = 24'06 2020
Luxon
console.warn(DateTime.fromJSDate(new Date("06/24/2020")).toFormat('dd\'MM yyyy')); // output is = 24MM yyyy
moment.js deprecated according to its documentation, So I used Luxon in my react project. I need to format the date like DD'MM yyyy, Luxon does not accept this format while MomentJs successfully did it. If you guys find any way to handle this in Luxon please answer:
MomentJS
moment('06/24/2020').format('DD\'MM yyyy') // output is = 24'06 2020
Luxon
console.warn(DateTime.fromJSDate(new Date("06/24/2020")).toFormat('dd\'MM yyyy')); // output is = 24MM yyyy
Share
Improve this question
asked Sep 27, 2020 at 10:05
SandeepSandeep
1,4791 gold badge13 silver badges27 bronze badges
1 Answer
Reset to default 6Luxon uses single quotes as an escape character, so it's currently not possible to insert a literal single quote. According to Luxon GitHub issue #649 Escaping single quote, it seems like this is a known limitation.
Short of opening a PR yourself, you could work around it like this:
DateTime.fromJSDate(new Date('06/24/2020')).toFormat('dd!MM yyyy')
.replace('!', "'")
本文标签: javascriptLuxon does not format (DD39MM yyyy) formatStack Overflow
版权声明:本文标题:javascript - Luxon does not format (DD'MM yyyy) format - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744057282a2526078.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论