Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change primeNG datatable p-column filter date format?

How and is it possible to change date format when filtering by date?

<p-columnFilter type="date" [field]="col.field" display="menu">

Default format is mm/dd/yyyy but I want to achieve dd/mm/yyyy

like image 259
Kruno Avatar asked Sep 15 '25 16:09

Kruno


1 Answers

You can do this by configuring the PrimeNgConfig:

in your i18n assets (could also be just a typescript constant):

"primeng": {
    ...
    "dateFormat": "dd.mm.yy",
    ...
 }

Then inject PrimeNgConfig in your app components constructor:

private primeNgConfig: PrimeNGConfig

In ngOnInit you can set the configuration:

this.translate.get('primeng').subscribe(res => this.primeNgConfig.setTranslation(res))

More documentation on here: https://www.primefaces.org/primeng/i18n

like image 173
Stefan Avatar answered Sep 17 '25 08:09

Stefan