I'm submitting a ...
[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Plunkr Case (Bug Reports)
dateFormat option from calendar locale is not working althought it is mentioned in documentation
https://stackblitz.com/edit/primeng-calendar-demo-jcvw77
Current behavior
default mm/dd/yy is used
Expected behavior
dd.mm.yy should be shown
I'm having the same issue,
The placeholder work but the field in the component not work, I'm traying to set 麓MM/DD/YYYY麓 or 麓DD/MM/YYYY麓 , however if I set 麓dd/mm/yyyy麓 in lowercase show for example 10/08/20202020.
Just use dateFormat="dd.mm.yy"
change it on https://stackblitz.com/edit/primeng-calendar-demo-jcvw77
Just use dateFormat="dd.mm.yy"
I know this is possible, but I want to set this global and not for every p-calendar tag in the html file
or [dateFormat]="[locale].dateFormat" in html
I know it is possible, you don麓t have to tell me.
But its a bug either in documentation or in the component. the documentation clearly says:
_"Default date format is mm/dd/yy, to customize this use dateFormat property or define it at locale settings"._
I don麓t need a workaround I just point out an issue.
Hello PrefEibe,
I had the same problem. I want to have the locale settings global in one place, which will be used for all date pickers.
The problem here is the following in the calendar component:
The dateFormat will be defaulted if nothing is specified:
@Input() dateFormat: string = 'mm/dd/yy';
This default value leads to the locale.dateFormat will never be used,:
getDateFormat() {
return this.dateFormat || this.locale.dateFormat;
}
If you set the dateFormat input to null, it works with the locale.dateFormat:
<p-calendar [(ngModel)]="date2" [dateFormat]="null" [locale]="de"></p-calendar>
I hope this will be fixed soon, to avoid the [dateFormat]="null" in every datePicker.
Hello, maybe then next time one could write also some workaround in report until it is fixed, we could have 7 comments less now.
This is not an issue but I agree that a global config to always consider locale setting first could be an option e.g. PrimeNGConfig class of 10.
@cagataycivici @ProfEibe
Hello, I provided a PR #9387 for this one since I need this feature too because I have a large Angular application and it is painful to set the locale for every single calendar component.
You can use new i18n API.
Regards.
Most helpful comment
@cagataycivici @ProfEibe
Hello, I provided a PR #9387 for this one since I need this feature too because I have a large Angular application and it is painful to set the locale for every single calendar component.