Mayur Bhatt
Mayur Bhatt

Reputation: 65

Not able to use datepipe with locale format

I am building website using angular2 final and webpack cli. I have requirement to display date in locale nl-NL, my html code looks like:

{{eventDate | date:'d MMMM y'}}

it displays date like:

5 January 2016

It should display

5 januari 2016

any help will be much appreciated, Thanks in advance.

Upvotes: 5

Views: 7148

Answers (1)

Stefan Svrkota
Stefan Svrkota

Reputation: 50633

Since RC6, there is an option to set default locale. You can do it in your AppModule, first you need to import LOCALE_ID:

import { LOCALE_ID } from '@angular/core';

Then you can change its default us-US value in your module's providers, in your case nl-NL:

@NgModule({
    imports: [...],
    declarations: [...],
    bootstrap: [...],
    providers: [
        { provide: LOCALE_ID, useValue: "nl-NL" }
    ]
})

Here's working plnkr: http://plnkr.co/edit/YRULhoEqurClE8G16TlC?p=preview

Upvotes: 13

Related Questions