ios - 如何在 iOS objective-c 中将 firebase 时间戳转换为日期?

标签 ios objective-c firebase firebase-realtime-database timestamp

我使用 firebase 生成的 TIMESTAMP 将我的数据保存在 firebase 中。我需要在我的 iOS 应用程序中转换它们。我尝试按照以下方式进行操作,但返回的结果很复杂。

NSDate *date = [NSDate dateWithTimeIntervalSince1970:1493292606524];
NSLog(@"Date: %@", date);

它返回 Date: 49290-07-23 05:48:44 +0000

上面的问题是什么?结果应该是今天的日期。 (2017-04-27)

最佳答案

try this need to convert this stamp into seconds

NSDate *date = [NSDate dateWithTimeIntervalSince1970:(1493292606524/1000)];
NSLog(@"Date: %@", date);

关于ios - 如何在 iOS objective-c 中将 firebase 时间戳转换为日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43657274/

相关文章:

ios - 缩小后的 UILabel 的质量

objective-c - 在 iOS 5 中关闭多个 View Controller

objective-c - 在空 NSDictionary 上调用 valueForKey

android - 如何获取 Firebase android 中所有 child 的列表?

ios - 缺少所需的模块 'libxml2'

ios - 保存 ManagedObjectContext 时处理错误

iphone - 查看过渡动画

java - 为什么字符串不能转换为对象类

android - 如何在 firebase 消息服务中添加 View ?

ios - iPad 2 多处理?