Sripter
Sripter

Reputation: 21

Angular date pipe

I am using Angular 8 date Pipe and manually set the LOCAL to 'en-GB'. But the output of the date pipe still is in the US format (mm/dd/yyyy). Any idea what's the issue? or Am I missing something?

const datePipe = new DatePipe('en-GB');
return datePipe.transform(value, 'short');

Upvotes: 1

Views: 737

Answers (1)

surendra kumar
surendra kumar

Reputation: 1780

You need to write the below code.

import { registerLocaleData } from '@angular/common';
import localeGB from '@angular/common/locales/en-GB';

registerLocaleData(localeGB, 'en-GB');

...

providers: [{ provide: LOCALE_ID, useValue: 'en-GB' }]

Upvotes: 3

Related Questions