It's been a few hours that I'm trying to figure this out.
I'm trying to simply convert a timestamp Timestamp(seconds=1555755972, nanoseconds=393000000)
into a normal date dd/mm/yyyy.
I'm getting a list of documents from firestore, then I pass them through my component:
export class MissionComponent implements OnInit {
missions: Mission[];
mission: any = {};
constructor(
private missionService: MissionService,
private datePipe: DatePipe)
{}
ngOnInit() {
this.missionService.getMissions().subscribe(data => {
this.missions = data.map(e => {
return{
id: e.payload.doc.id,
...e.payload.doc.data()
} as Mission;
});
});
}
and then I show few fileds thorugh a for cycle in the html:
<tr *ngFor="let mission of missions">
..
<td>{{mission.dataRitiro.toDate() }}</td>
<td>{{mission.dataConsegna.toDate() }}</td>
...
mission.dataRitiro
gives me Timestamp(seconds=1555755972, nanoseconds=393000000)
If I'm converting the mission.dataRitiro
with .toDate()
I'm getting Wed Apr 03 2019 00:00:00 GMT+0200 (Ora legale dell’Europa centrale)
untill here everithing works, but I want to get 03/04/2019
, so, searching in internet I've found the method datePipe
, I just need to write mission.dataRitiro.toDate() | date: 'dd/mm/yyyy'
but if I wirte it inside the html I just get a blank field and in console I'm getting this error
Error: InvalidPipeArgument: 'Missing locale data for the locale "it-IT".' for pipe 'DatePipe'
at...
but in my app.module I've imported
import { NgModule, LOCALE_ID } from '@angular/core';
and inserted inside the providers
{ provide: LOCALE_ID, useValue: "it-IT" }
So at this point I really don't know what to do. Thankyou guys.