문제

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