0

Angular DatePipe does not look to have some way to format date patterns based on a pattern and change the pattern based on the language.

The default when using DatePipe is medium. But i wwant to use this format yyyy-MM-dd for english. However, other countries like Italy use this format dd.mm.yy

So if I do this:

formatDate(date, 'yyyy-MM-dd', this.translateService.currentLang);

and the language is it

inside, it should format the date with the pattern dd.mm.yy but that piece of code will still output it with format yyyy-MM-dd

Is this a limitation? Is the best recourse to use moment?

chitgoks
  • 311
  • 2
  • 6
  • 17
  • I believe a simple approach is to use `input type='datetime-local' ...>` that will set the date format based on user locale – Owen Kelvin Oct 17 '20 at 03:51
  • how about if its basic output? like in {{ mydate | date .... }} is that possible? – chitgoks Oct 18 '20 at 04:08
  • i believe this post should help https://stackoverflow.com/questions/34904683/how-to-set-locale-in-datepipe-in-angular-2 – Owen Kelvin Oct 18 '20 at 05:17

0 Answers0