admin管理员组

文章数量:1124379

I'm still confused about the DatePicker of Angular Material. I have to achieve three things:

  1. Have another language used
  2. Have another date format used
  3. Have the bug fixed, where the time part of the date changes the date information by one day.

I think there should be a generic way to fix all of them. But trying to find a solution there are only problems and almost no answers: @1. Even the stack blitz implementation of is not working. The text is always English. The corresponding link is: .ts I tried to find information how I can use the MatDatepickerIntl service but setting any of the properties is also ignored and I can't find a working example.

@2. I found examples where I can add a fixed date format. But I want to have the date format depending on the locale. One time I managed to use e.g. a German locale but there the format was d.m.yyyy instead of dd.mm.yyyy. Do I really have to implement the different formats for every possible locale by my self?

@3. I wondered why my date, read from a date picker and stored in a database always was a day back. Than I have read that this is an old problem and one have to always add some hours to the date so it can be truncated to a date information without any time parts. Isn't there any better solution to this? And if there is not, how can I apply this to every date field automatically like an interceptor?

I hope someone can help me because I'm really stuck on this.

Best regards

Parascus

I'm still confused about the DatePicker of Angular Material. I have to achieve three things:

  1. Have another language used
  2. Have another date format used
  3. Have the bug fixed, where the time part of the date changes the date information by one day.

I think there should be a generic way to fix all of them. But trying to find a solution there are only problems and almost no answers: @1. Even the stack blitz implementation of https://v5.material.angular.io/components/datepicker/examples is not working. The text is always English. The corresponding link is: https://stackblitz.com/angular/vjgvmmmxpqj?file=app%2Fdatepicker-locale-example.ts I tried to find information how I can use the MatDatepickerIntl service but setting any of the properties is also ignored and I can't find a working example.

@2. I found examples where I can add a fixed date format. But I want to have the date format depending on the locale. One time I managed to use e.g. a German locale but there the format was d.m.yyyy instead of dd.mm.yyyy. Do I really have to implement the different formats for every possible locale by my self?

@3. I wondered why my date, read from a date picker and stored in a database always was a day back. Than I have read that this is an old problem and one have to always add some hours to the date so it can be truncated to a date information without any time parts. Isn't there any better solution to this? And if there is not, how can I apply this to every date field automatically like an interceptor?

I hope someone can help me because I'm really stuck on this.

Best regards

Parascus

Share Improve this question asked 2 days ago parascusparascus 1,2291 gold badge11 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Ok, I have done some progress:

@1: Still not clarified. I will open another request with my code.

@2: I accepted that there is no way to select a locale that has a leading zero so I have to work on every locale as soon I try to add a new language.

@3: For this problem I advise the solution of Bruno Cerecetto in the request day incorrect in angular material datepicker. That worked for me.

Best regards

Parascus

本文标签: Angular Material DatePicker Example not workingStack Overflow