How get a datetime column in SQLite with Objective C

前端 未结 5 1134
野趣味
野趣味 2020-11-28 11:29

How do you get a datetime column in SQLite with Objective C?

I have a table with 4 fields: pk, datetime, value1 and valu

5条回答
  •  渐次进展
    2020-11-28 12:19

    If you just want to get an NSDate from an SQLite datetime field, where dateTime is the field returned from the database:

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *date = [dateFormatter dateFromString:dateTime];
    

提交回复
热议问题