gpt4 book ai didi

iphone - unix 时间戳到几小时前

转载 作者:行者123 更新时间:2023-11-29 04:40:36 24 4
gpt4 key购买 nike

我有以下代码:

 NSDate *commentPostedDate = [[NSDate alloc] initWithTimeIntervalSince1970:[self.newsFeedStream_.timestamp_ intValue]];
NSLog(@"TIMESTAMP IS %@", self.newsFeedStream_.timestamp_);

int interval = (int) [[NSDate date] timeIntervalSinceDate:commentPostedDate] / 60;
[commentPostedDate release];

NSString *timePosted = [NSString stringWithFormat:@"%d hours ago", interval];

但是,这似乎没有返回正确的小时前。我在这里做错了什么?

最佳答案

UNIX 时间戳通常以秒为单位,那么如果您想要小时,为什么要除以 60?

一小时有 3600 秒,而不是 60 秒。

关于iphone - unix 时间戳到几小时前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10456974/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com