Error when inserting NSDate to CoreData

后端 未结 1 922
暖寄归人
暖寄归人 2021-01-24 03:03
    NSDateFormatter *dt = [[NSDateFormatter alloc] init];
    [dt setDateFormat:@\"dd-MM-yyyy\"];
    NSDate *bdate = [dt dateFromString:@\"02-02-2013\"];
    [nouContac         


        
相关标签:
1条回答
  • 2021-01-24 03:19

    For a "Date" attribute, Core Data stores the "number of seconds since 1 January 2001, GMT" in the SQLite file, i.e. what you get with

    [bdate timeIntervalSinceReferenceDate]
    

    For example, 2011-02-02 19:00:00 +0000 is stored as the number 318366000.

    But that is an implementation detail and you should not worry about it. When reading objects from the SQLite file, the number is converted back do an NSDate.

    0 讨论(0)
提交回复
热议问题