【问题标题】:Weird data format from firestore db来自 firestore db 的奇怪数据格式
【发布时间】:2019-12-30 23:00:40
【问题描述】:

我在 Firestore 中的数据是这样的:

Timestamp(seconds=1566840930, nanoseconds=491000000)

由于它不是有效的 unix 时间戳,我不知道如何以可读的名称显示它,例如 dd.mm.yy。

我正在获取组件中的数据:

@Component({
  firestore() {
    return {
      linksArray: db.collection('links')
    }
  }
})

然后使用v-for 显示链接列表。

【问题讨论】:

    标签: javascript typescript vue.js google-cloud-firestore


    【解决方案1】:

    你有一个Firestore Timestamp object,定义为:

    时间戳表示独立于任何时区或日历的时间点,以 UTC 纪元时间纳秒分辨率的秒数和秒数表示。

    因此(与 UNIX 时间戳一样)它表示相对于 UTC 纪元时间的时间点,但(与 UNIX 时间戳不同)它以纳秒分辨率表示这个时间。

    如果您想获得 UNIX 时间戳所在的毫秒分辨率,请在 Timestamp 上调用 toMillis()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      • 1970-01-01
      • 2021-11-02
      • 1970-01-01
      • 2018-11-17
      • 2022-11-14
      • 1970-01-01
      相关资源
      最近更新 更多