Reputation: 21
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
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