A Swift date, several possible origins
In Foundation, Date represents an instant. To exchange it as a number, specify the origin and unit. timeIntervalSince1970 provides seconds since the Unix Epoch; timeIntervalSinceReferenceDate uses January 1, 2001 as its reference.
import Foundation
let date = Date(timeIntervalSince1970: 1711972800)
let formatter = ISO8601DateFormatter()
print(formatter.string(from: date))
// 2024-04-01T12:00:00Z
print(date.timeIntervalSince1970)
// 1711972800.0Convert the 2001 reference to Unix
The Foundation reference is offset by 978,307,200 seconds from the Unix Epoch.
let referenceSeconds: TimeInterval = 733665600
let date = Date(timeIntervalSinceReferenceDate: referenceSeconds)
print(date.timeIntervalSince1970) // 1711972800.0Do not generalize to every Apple file
An application database, photo metadata or system log may use a different representation: seconds, nanoseconds, a date string, an explicit time zone or none at all. The Apple name alone does not determine the format. Check the schema and compare a value whose date is known.
To use our Unix converter with a value relative to 2001, convert the origin first, then select the correct unit. Simply multiplying by 1,000 does not correct a different origin.
References
English version published September 26, 2026.