Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 664
Mayur Bhatt Avatar asked Dec 19 '22 13:12

Mayur Bhatt


1 Answers

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

like image 54
Stefan Svrkota Avatar answered Jan 02 '23 14:01

Stefan Svrkota