gpt4 book ai didi

ios - NSPredicate 和 NSDate 的奇怪行为

转载 作者:行者123 更新时间:2023-12-01 18:15:52 25 4
gpt4 key购买 nike

我正在尝试使用 NSPredicate 过滤结果,但我在 NSPredicate 中使用 NSDate 时有一个奇怪的行为。

这是代码;

NSDate *auctionDate = obj[@"auctionDate"];
NSLog(@"%@", auctionDate);
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"auctionDate == %@", auctionDate];
NSLog(@"%@", predicate);

这是 NSLog 输出;
2014-02-21 00:00:00 +0000
auctionDate == CAST(414633600.000000, "NSDate")

如您所见,每个 NSLog 都显示 NSDate 和 NSPredicate 字符串,但如果仔细观察,NSPredicate 创建的 NSDate 和 UNIX 时间戳并不相等。

414633600.0 转换为日期是“Mon, 21 Feb 1983 00:00:00 GMT”,不等于原始 NSDate。

任何的想法?

提前致谢

最佳答案

NSDate 使用的引用日期是 2001 年 1 月 1 日,格林威治标准时间

不是 1970 年。

关于ios - NSPredicate 和 NSDate 的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21909827/

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