How does the iPhone SDK Core Data system store date types to sqlite?

Posted by Andrew Arrow on Stack Overflow See other posts from Stack Overflow or by Andrew Arrow
Published on 2010-03-22T17:54:34Z Indexed on 2010/03/22 18:11 UTC
Read the original article Hit count: 291

Filed under:
|
|
|

I used core data to do this:

NSManagedObjectContext *m = [self managedObjectContext];
Foo *f = (Foo *)[NSEntityDescription insertNewObjectForEntityForName:@"Foo" 
                                                        inManagedObjectContext:m];
f.created_at = [NSDate date];
[m insertObject:f];

NSError *error;
[m save:&error];

Where the created_at field is defined as type "Date" in the xcdatamodel.

When I export the sql from the sqlite database it created, created_at is defined as type "timestamp" and the values look like:

290902422.72624

Nine digits before the . and then some fraction.

What is this format? It's not epoch time and it's not julianday format.

Epoch would be:

1269280338.81213

julianday would be:

2455278.236746875 (notice only 7 digits before the . not 9 like I have)

How can I convert a number like 290902422.72624 to epoch time? Thanks!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about date