【发布时间】:2019-02-21 10:18:13
【问题描述】:
我想知道如何将数据以String 发布到Firestore 为Timestamp。我正在创建一个示例应用程序,它将数据存储在tableView 上,并且数据将根据Timestamp 进行排序。
因此,在编程中,我尝试将当前时间和日期设为String,但我不知道如何将数据设置为Firestore,因为字段为Timestamp。当我从Firestore 查询数据时,我想根据Timestamp 对数据库进行排序。
let currentDateTime = Date()
// initialize the date formatter and set the style
let formatter = DateFormatter()
formatter.timeStyle = .long
formatter.dateStyle = .long
// get the date time String from the date object
formatter.string(from: currentDateTime)
Firestore 中的Timestamp 包含日期和时间。
如何将数据以String 发布到FirestoreTimestamp?
【问题讨论】:
标签: swift firebase timestamp google-cloud-firestore