- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我是iOS编程新手。我正在创建一个与 Firestore
集成的简单程序。在 Firestore
中,我创建了集合,每个文档都包含许多字段。
我在文档中添加了 Timestamp
字段。当我在 xcode
中创建模型时,我如何将我的变量声明为 Timestamp
因为我需要根据 Timestamp 对
。tableView
上的数据进行排序
这是 Firestore
中的 Timestamp
的样子:
2018 年 9 月 17 日下午 3:37:43 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
}
}
最佳答案
不熟悉 Firebase。但通常,在 iOS 中,我们将时间戳存储为 TimeInterval
,它是 Double
的类型别名。
class func getDateOnly(fromTimeStamp timestamp: TimeInterval) -> String {
let dayTimePeriodFormatter = DateFormatter()
dayTimePeriodFormatter.timeZone = TimeZone.current
dayTimePeriodFormatter.dateFormat = "MMMM dd, yyyy - h:mm:ss a z"
return dayTimePeriodFormatter.string(from: Date(timeIntervalSince1970: timestamp))
}
关于swift - 如何在 ios 中将数据类型声明为时间戳 - swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52367721/
给定一个带有多个 date_time 戳的字符串,我想 提取第一个戳及其前面的文本 候选字符串可以有一个或多个时间戳 后续的 date_time 戳记将被 sep="-" 隔开 后续date_time
是否可以合并从相机拍摄的文本和照片?我想在照片上标记日期和时间,但我在 Google 上找不到任何内容。 最佳答案 使用下面的代码来实现你所需要的。 Bitmap src = Bitm
有没有办法通过 Graph API 戳另一个用户?基于this post ,并使用 Graph Explorer ,我发布到“/USERID/pokes”,我已经授予它(Graph API 应用程序和
我有两个向左浮动的元素。一个是 body 的第一个 child ,另一个是容器的第一个 child ,容器是 body 的第二个 child 。 ...
我是一名优秀的程序员,十分优秀!