【发布时间】:2014-03-21 12:22:06
【问题描述】:
我正在尝试使用 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。
有什么想法吗?
提前致谢
【问题讨论】:
标签: ios timestamp nsdate nspredicate behavior