【发布时间】:2019-02-21 09:03:05
【问题描述】:
我是一个新的iOS编程。我正在创建一个与Firestore 集成的简单程序。在Firestore 我创建了集合,每个文档都包含许多字段。
我在文档中添加了Timestamp 字段。当我在xcode 中创建模型时,我如何将我的变量声明为Timestamp,因为我需要基于Timestamp 对tableView 上的数据进行排序。
这就是Firestore 中的Timestamp 的样子:
September 17, 2018 at 3:37:43 PM UTC+7
那么,我如何编写程序并获得当前的Timestamp,就像在Firestore 中显示的那样
这是在编程中:
struct RecentCallModel {
var call_answered: Bool?
var call_extension: String?
var call_type: String?
var details: String?
var duration: String?
var title: String?
// How can i declare as Timestamp
var timestamp: ???
init(call_answered: Bool, call_extension: String, call_type: String, details: String , duration: String, timestamp: String, title: String) {
self.call_answered = call_answered
self.call_extension = call_extension
self.call_type = call_type
self.details = details
self.title = title
}
}
【问题讨论】:
-
简单使用
Double -
如何在编程中获取当前的
Timestamp?? -
Firestore 应该将该字段返回为
Timestamp类型。您可以通过在其上使用.dateValue()方法获得Date
标签: swift firebase timestamp google-cloud-firestore