angular - 如何使用角度日期管道转换 Firebase 时间戳
问题描述
我正在尝试在模板视图中显示一些 firebase 时间戳,不幸的是,角度 datePipe 没有运气。
<p>Seen {{user.updatedAt | date: 'yyyy/MM/dd h:mm:ss a'}}</p>
我确实收到此错误:
ERROR Error: InvalidPipeArgument:
'Unable to convert "Timestamp(seconds=1528515928, nanoseconds=105000000)"
into a date' for pipe 'DatePipe
解决方案
您可以将时间戳转换为毫秒或日期:
<p>Seen {{user.updatedAt.toMillis() | date:'yyyy/MM/dd h:mm:ss a'}}</p>
或者
<p>Seen {{user.updatedAt.toDate() | date:'yyyy/MM/dd h:mm:ss a'}}</p>
推荐阅读
- python - 无法安装 mysql 客户端 1.3.12 出现致命错误 C1083:无法打开包含文件:'mysql.h':没有这样的文件或目录
- applescript - 如何使用 AppleScript 在当前激活桌面中打开新应用程序?
- postgresql - 允许在边界重叠的排除约束
- r - r 将不等于 1 或 2 或 3 的值替换为其他值
- java - JFreeChart:使用 ChartMouseEvent 在散点图上显示数据
- vagrant - Vagrant 在执行 'vagrant up' 时抛出错误
- python - 获取艺术家信息的 Artsy api 几乎是空的
- java - 如何使用 BufferedReader 从 PrintWriter 读取 txt 文件以读取具有值的网格坐标?
- python - 有人可以解释为什么我的 .propagate(False) 不起作用吗?
- r - 如何增加具有离散 x 轴 - position_dodge 的箱线图(ggplot2)之间的距离?