jen*_*ent 12 javascript date luxon
我已经浏览了文档,但找不到帮助程序来重置 Luxon DateTime 的时间。
我可以从一个标准日期开始:
export const getDateOnly = (date: Date = new Date()) => new Date(
date.getFullYear(),
date.getMonth(),
date.getDate()
)
export const today = () => DateTime.fromJSDate(getDateOnly());
Run Code Online (Sandbox Code Playgroud)
但这似乎是一个常见的场景,我可能只是错过了它?
Spe*_*051 22
重新发布作为答案以供将来参考。
https://moment.github.io/luxon/api-docs/index.html#datetimestartof
举例来说:
export const today = () => DateTime.now().startOf('day');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12962 次 |
| 最近记录: |