Converting Apple Cocoa, Core Data, and iOS SQLite Timestamps
Opening an iOS Core Data SQLite file or Safari History.db shows 9-digit numbers like 786585600 instead of standard 10-digit Unix timestamps. Pasting that number into a regular epoch tool drops your iPhone event back to December 1994 because Apple counts time from the year 2001.
The Apple Cocoa Epoch: January 1, 2001 UTC
Apple frameworks (including NSDate, CFAbsoluteTime, Swift Date, and Core Data) start counting at January 1, 2001 at 00:00:00 UTC, known as Mac Absolute Time or the Cocoa Epoch. Exactly 978,307,200 seconds (31 years) separate January 1, 1970 from January 1, 2001.
SQLite Formulas for Core Data and iMessage
To convert a standard Apple Core Data or Safari timestamp to Unix seconds, add 978307200:
-- Core Data / Safari History.db (seconds since 2001)
SELECT datetime(visit_time + 978307200, 'unixepoch') AS utc_time
FROM history_visits;
Modern iOS and macOS versions store iMessage chat.db timestamps in nanoseconds since 2001 instead of seconds, producing 18-digit values. Divide by 1,000,000,000 first before adding the Apple offset:
-- iMessage chat.db on modern macOS / iOS (nanoseconds since 2001)
SELECT datetime((date / 1000000000) + 978307200, 'unixepoch') AS msg_utc
FROM message;
Swift Conversion Reference
In Swift, use timeIntervalSince1970 instead of timeIntervalSinceReferenceDate whenever sending timestamps to external backend APIs, as noted in the Apple Foundation Date documentation.