Iphone Sqlite Nsdate Bug
Solution 1:
In some cases you'll need to add 31 years to the dates in the SQLite DB.
From the book: IPhone Forensics: Recovering Evidence, Personal Data, and Corporate Assets By Jonathan Zdziarski On calendar events:
Unlike most timestamps used on the iPhone, which are standard Unix time-stamps, the timestamp used here is an RFC 822 timestamp representing the date offset to 1977. To convert this date, determine the actual RFC 822 time-stamp and add 31 years.
Solution 2:
For doing any query or other SQLLite operation, you should always (always!!!) use bind variables. So the query would look like:
zdate > ?
Then you make a prepared statement, bind the date variable, and execute the statement to get your results.
Solution 3:
I haven't checked this, but off the top of my head I'd guess that sqlite expects a different date format. Consider using an NSDateFormatter to convert it to the one sqlite uses.
Solution 4:
Wrong usage of NSDate in predicate!
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date > %@",yearAgo]; - worng
I must use this:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date > '%f'",[yearAgo timeIntervalSinceReferenceDate];
And all works.
Post a Comment for "Iphone Sqlite Nsdate Bug"