Persisting Dates to SQLite3 in an iPhone Application

后端 未结 5 1783
忘掉有多难
忘掉有多难 2020-12-05 03:31

I am developing an iPhone application that persists data to a SQLite3 database.

For each row I persist I wish to include a \'created date\' and a \'last modified da

5条回答
  •  庸人自扰
    2020-12-05 03:45

    I typically use a double, something like:

    sqlite3_bind_double(statement, index, [dateObject timeIntervalSince1970]);
    

    where dateObject is an NSDate*. Then, when getting the data out of the DB, use

    [NSDate dateWithTimeIntervalSince1970:doubleValueFromDatabase];
    

提交回复
热议问题