我将服务器值时间戳保存如下:
let data : [String: Any] = ["userId": 9,
"name": "Elon Musk",
"timeCreated": ServerValue.timestamp()]
let doc = firestore.collection("orders").document()
doc.setData(data){ (error) in
}在查看Firestore时,我看到了以下内容:

这是正常的吗?难道不应该有一个包含自Unix时代以来的毫秒数的长整型吗?
发布于 2018-01-13 08:24:07
您使用的是服务器时间戳的实时数据库概念,即ServerValue.timestamp。它本质上是一个字典,其中包含您所显示的值:{'.sv': 'timestamp'}。这与Firestore不兼容。
相反,您希望使用Firestore的服务器时间戳概念,即FieldValue.serverTimestamp()。另请参阅documentation here中的最后一个示例。
发布于 2018-01-13 05:51:53
不,这看起来不正常。这是我使用ServerValue.timestamp()时得到的结果。

https://stackoverflow.com/questions/48234148
复制相似问题