我在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的那个)
谢谢!!
您所看到的实际上是Firestore的Timestamp
class的内部表示形式。
如果要获取自该纪元以来的毫秒数,则可以调用toMillis()
timestamp对象。
所以像:
console.log(profile.date_of_birth.toMillis())
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句