我正在尝试使用角度上的管道,特别是以下内容:{{fechaCreacion | date: 'medium'}}和我得到了以下错误:Unable to convert Timestamp (seconds = 1528157765, nanoseconds = 878000000)" into a date 'for pipe' DatePipe'
这是我在Firestore的注册:

当我刚离开{{ fechaCreacion }}时,它向我展示了以下内容:

我该怎么解决呢?
我在用:
角6
"angularfire2":"^5.0.0-rc.10“
“火源”:"^5.0.4",
component.ts
aviso: any = {};
id;
titulo;
descripcion;
fechaCreacion;
categoria;
constructor( private fs: FirebaseService, private activatedRoute: ActivatedRoute) { }
ngOnInit() {
this.id = this.activatedRoute.snapshot.params['id'];
this.fs.getAvisoObject(this.id).valueChanges().forEach(aviso => {
this.titulo= aviso.titulo,
this.descripcion = aviso.descripcion,
this.fechaCreacion = aviso.fechaCreacion,
this.categoria = aviso.categoria
});
}component.html
<mat-card class="px-3 px-md-5 py-3 py-md-4 rounded">
<div class="row no-gutters small pb-2 mb-3 d-flex justify-content-between border-bottom text-muted">
<div>
<span>{{ categoria }}</span>
</div>
<div>
<span>{{ fechaCreacion | date : 'medium' }}</span>
</div>
</div>
<h2 class="font-weight-bold">{{ titulo }}</h2>
<h5 class="font-weight-light">{{ descripcion }}</h5>
</mat-card>service.ts
getAvisoObject(id: string) {
this.avisoObject = this.afs.doc('avisos/' + id);
return this.avisoObject;
}发布于 2018-06-20 20:41:33
发布于 2018-06-22 11:48:46
您必须调用toDate()将Firebase时间戳转换为管道之前的Javascript日期对象,例如:
{{ creationDate.toDate() | date: 'medium' }}
发布于 2019-07-24 10:50:11

<ion-col size="4" class="top-center" item-end>
<ion-label class="second-col second-col-color text-align-right">{{ud.date.toDate() | date: 'dd/MM/yyyy'}}</ion-label>
</ion-col>
将其转换为toDate:date.toDate()
https://stackoverflow.com/questions/50956255
复制相似问题