日期垫数据选择器格式错误
我想要以 DD/MM/YYYY 格式显示日期。我需要使用带有数据选择器的意大利语和此格式 DD/MM/YYYY。 在我的 app.module 中,我这样做:
export const DD_MM_YYYY_Format = {
parse: {
dateInput: 'DD/MM/YYYY',
},
display: {
dateInput: 'DD/MM/YYYY',
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
};
在我的提供程序中这样做之后:
{ provide: MAT_DATE_LOCALE, useValue: 'it-IT' },
{provide: MAT_DATE_FORMATS, useValue: DD_MM_YYYY_Format},
所以我在我的组件中这样做,但格式不正确。结果是这样的:
问题是我想要格式“02/03/2022
”而不是“2/3/2022
” '
I want show date with this format DD/MM/YYYY. I need to use italian languages with data picker and this format DD/MM/YYYY.
In my app.module I do this:
export const DD_MM_YYYY_Format = {
parse: {
dateInput: 'DD/MM/YYYY',
},
display: {
dateInput: 'DD/MM/YYYY',
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
};
and after I do in my providers :
{ provide: MAT_DATE_LOCALE, useValue: 'it-IT' },
{provide: MAT_DATE_FORMATS, useValue: DD_MM_YYYY_Format},
So I do in my component and the format is not properly correctly. the result is this:
the problem is that I want the format '02/03/2022
' and not '2/3/2022
'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将日期管道添加到输入字段引用 angular.io/api/common/DatePipe。
您似乎正在寻找这个管道:
Add a date pipe to your input field ref angular.io/api/common/DatePipe.
You seem to be looking for this pipe: