我在 Firestore 中的数据看起来是这样的:
时间戳(秒=1566840930,纳秒=491000000)
因为它不是有效的 unix 时间戳,所以我不知道如何以可读的名称显示它,例如 dd.mm.yy。
我正在组件中获取数据:
@Component({
firestore() {
return {
linksArray: db.collection('links')
}
}
})
然后使用 v-for
显示链接列表。
最佳答案
你有一个 Firestore Timestamp
object ,定义为:
A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.
因此(与 UNIX 时间戳一样)它表示相对于 UTC 纪元时间的时间点,但(与 UNIX 时间戳不同)它以纳秒分辨率表示这个时间。
如果您想获得 UNIX 时间戳所在的毫秒分辨率,请调用 toMillis()
在时间戳
上。
关于javascript - 来自 firestore db 的奇怪数据格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57663222/