我正在使用Fluent UI和React JSX
进行一个项目,我的问题是如何将DatePicker组件的日期格式化为day.month.year
格式?
示例:
<DatePicker
...
formatDate={(date) => {
return (date.getMonth() + "." + date.getDate() + "." + date.getFullYear)
}}
/>
发布于 2021-12-06 10:28:38
如果要格式化DatePicker Component
的日期,请使用formatDate
方法:
const formatDate = (date?: Date): string => {
if (!date) return '';
const month = date.getMonth() + 1; // + 1 because 0 indicates the first Month of the Year.
const day = date.getDate();
const year = date.getFullYear();
return `${day}.${month}.${year}`;
}
<DatePicker
...
formatDate={formatDate}
/>
有用的链接:
https://stackoverflow.com/questions/70237148
复制相似问题