Angular date pipe

711 Views Asked by At

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');
1

There are 1 best solutions below

0
On

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' }]