質問

I'm trying to filter results with NSPredicate but I have an strange behavior with NSDate in a NSPredicate.

Here is the code;

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

And this is the NSLog output;

2014-02-21 00:00:00 +0000
auctionDate == CAST(414633600.000000, "NSDate")

As you can see, every NSLog shows NSDate and NSPredicate string, but if you look more closely, NSDate and UNIX timestamp created by NSPredicate are not equal.

414633600.0 converted to date is "Mon, 21 Feb 1983 00:00:00 GMT" that are not equal to original NSDate.

Any idea?

Thanks in advance

役に立ちましたか?

解決

The reference date used by NSDate is 1 January 2001, GMT

not 1970.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top