How to change data pipe Angular 6 date language?

Question:

I would like to change the language of the date of my app so that it is from Argentina, I tried with this configuration seeing the angular documentation but it still does not change. The default configuration is en-US. It does not show me any error by console

app.module.ts

import { registerLocaleData } from '@angular/common';
import localeEsAr from '@angular/common/locales/es-AR';
registerLocaleData(localeEsAr);

app.component.html

<td>{{resultado.date?.seconds * 1000| date:'fullDate'}}</td>

Answer:

What you need is to import the local angular common locales, also register them to be able to use them, that should solve your error of

'Missing locale data for the locale "es-AR"'

and if you keep throwing the same error, check your premises folder if it contains es-Ar, in your case you should only import es-Ar, in my example it shows several other premises

    import { LOCALE_ID, NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { AppComponent } from '../src/app/app.component';
    import { registerLocaleData } from '@angular/common';

    // importar locales
    import localePy from '@angular/common/locales/es-PY';
    import localePt from '@angular/common/locales/pt';
    import localeEn from '@angular/common/locales/en';
    import localeEsAr from '@angular/common/locales/es-AR';

    // registrar los locales con el nombre que quieras utilizar a la hora de proveer
    registerLocaleData(localePy, 'es');
    registerLocaleData(localePt, 'pt');
    registerLocaleData(localeEn, 'en')
    registerLocaleData(localeEsAR, 'es-Ar');

    @NgModule({
      imports: [ BrowserModule ],
      declarations: [ AppComponent ],
      // Aqui usas el nombre que hayas colocado al locale, en este caso es-Ar o pt o en, etc
      providers: [ { provide: LOCALE_ID, useValue: 'es-Ar' } ],
      bootstrap: [ AppComponent ]
    })
    export class AppModule { }
Scroll to Top