微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用带有日期的RelativeDateTimeFormatter 秒间隔?

如何解决如何使用带有日期的RelativeDateTimeFormatter 秒间隔?

我将事件的日期存储在 firebase 中。我有每个事件的秒、分、小时、日、周和年,但是当我想使用 RelativeDateTimeFormatter 时,它需要从事件到当前日期的总秒数。如何使用可用信息获取此信息或如何更好地使用它?代码

let exampleDate = Date().addingTimeInterval(-15000)
let formatter = RelativeDateTimeFormatter()
formatter.unitsstyle = .full
let relativeDate = formatter.localizedString(for: exampleDate,relativeto: Date())
cell.timeLabel.text = "\(relativeDate)"

我在 indexRow 中有日期信息,例如 payment.day 但什么是使 ReletiveDateTimeFormatter 为我工作并向我展示的正确格式和方法。 2 天前成功使用我的 Firebase 数据?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。