0

I'm using FMDatabase as sqlite wrapper for my iOS app, there's one place where I have to extract a date. I go like that:

....
ac.date=[s dateForColumn:@"date"];
NSLog(@"Date %@", ac.date);

But debug output gives me the following: Date 1970-01-01 00:33:32 +0000 Even though I've got dates like 2012-03-03 in my database, what can be wrong? thanks

Vladimir Stazhilov
  • 1,956
  • 4
  • 31
  • 63

1 Answers1

2

The FMDatabase code wants dates in the database as seconds from 1/1/1970 ie Unix time - if you have dates as strings like like 2012-03-03 then you will have to explicitly convert then from NSString to NSDate.

See this SO question for example code

Or you could alter the FMDatabase code in FMDatabase.m to bind dates as strings

Community
  • 1
  • 1
mmmmmm
  • 32,227
  • 27
  • 88
  • 117