Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度-角度材质格式-“;dd";及;yyyy“;小写字母不显示正确的格式_Javascript_Angular_Typescript - Fatal编程技术网

Javascript 角度-角度材质格式-“;dd";及;yyyy“;小写字母不显示正确的格式

Javascript 角度-角度材质格式-“;dd";及;yyyy“;小写字母不显示正确的格式,javascript,angular,typescript,Javascript,Angular,Typescript,在我的app.module.ts中,我已将我的应用程序格式更改为- export const MY_FORMATS = { parse: { dateInput: 'LL', }, display: { dateInput: 'yyyy-MM-dd', monthYearLabel: 'YYYY', dateA11yLabel: 'LL', monthYearA11yLabel: 'YYYY'

在我的app.module.ts中,我已将我的应用程序格式更改为-

export const MY_FORMATS = {
    parse: {
        dateInput: 'LL',
    },
    display: {
        dateInput: 'yyyy-MM-dd',
        monthYearLabel: 'YYYY',
        dateA11yLabel: 'LL',
        monthYearA11yLabel: 'YYYY',
    },
};

@NgModule({
    imports: [
        BrowserModule,
        HttpClientModule
        ...
    ],
    declarations: [
        AppComponent
        ...
    ],
    providers: [
        {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
        {provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
    ],
    bootstrap: [AppComponent],
})
export class AppModule { }
根据我的理解,“dd”代表“月中的一天”,而“dd”代表“年中的一天”,而“yyy”则表示日历年,而“yyy”则表示年份(一年中的一周)


但是在日期选择器中,我得到了这个日期——“yyyy-03-Tu”,只有当我将格式更改为“yyyy-MM-DD”时,我才能得到正确的日期。。知道为什么is是这样工作的吗?

您使用的是MomentDateAdapter,它使用及其格式规范

Momentjs使用:

  • YYYY
    对于4位年份-
    yyy
    无效,并被解释为文本
  • DD
    表示月份的两位数日
  • dd
    表示两位数的工作日

退房

谢谢!还有其他选择吗?我看到那些材料更喜欢MomentDateAdapter查看