我有一个数据模型,包括一个时间戳字段createdAt。
struct Box {
var title: String
var createdAt: Timestamp
var dictionary: [String : Any] {
return [
"title": title,
"createdAt": createdAt
]
}
// ...但是,我无法分配Fi还原服务器时间戳。什么是等效的数据类型的云固定服务器时间戳中的迅捷?我是不是漏掉了一点?
let box = Box(title: title, createdAt: FieldValue.serverTimestamp());发布于 2018-05-08 18:07:16
当从Timestamp读取Firestore时,可以将其转换为Date对象:
if let timestamp = data["createdAt"] as? Timestamp {
let date = timestamp.dateValue()
}/** Returns a new NSDate corresponding to this timestamp. This may lose precision. */
- (NSDate *)dateValue;Timestamp是一个FIRTimestamp对象,返回如下所示:
FIRTimestamp: seconds=1525802726 nanoseconds=169000000>
与.dateValue()的转换后
2018-05-08 18:05:26 +0000
https://stackoverflow.com/questions/50237336
复制相似问题