我在我的 firestore 数据库中存储了一个时间戳,但是当我想获取时间戳时,我得到了一些我无法解释的数字。也许有一种特殊的技术可以从我不知道的 vuejs 应用程序中的 firestore 中获取时间戳。
我的时间戳如下所示:
但是如果我输入以下命令来获取我的时间戳:
let ref = db.collection('profile').doc('profile_data')
ref.get().then(snapshot => {
profile = snapshot.data()
profile.id = snapshot.id
}).then( () => {
console.log(profile.date_of_birth)
})
我得到以下输出: 063147682800.000000000 与时间戳无关。 有人知道如何从我的 firestore 数据库中获取时间戳,以便我得到以下结果:1012086000000(这是我用来设置 date_of_birth 的那个)
谢谢!!
答案 0 :(得分:0)
您所看到的实际上是 Firestore 的 Timestamp
class 的内部表示。
如果您想获取自纪元以来的毫秒数,您可以在时间戳对象上调用 toMillis()
。
比如:
console.log(profile.date_of_birth.toMillis())