⭐ Starlight Tools / Apple Cocoa / Core Foundation Time

Apple Cocoa / Core Foundation Time Converter

Convert Apple CFAbsoluteTime (a.k.a. NSTimeInterval, seconds since 2001-01-01 UTC) to human-readable dates — and back. Fractional seconds supported. Fully client-side.

Related Tools

UNIX Timestamp Converter · LDAP / FILETIME Converter · Time Since / Until · Date Calculator

Results always include UTC; this controls the extra local view.
UNIX ↔ CF offset: 978307200 seconds (to/from 1970-01-01 UTC)

1) CFAbsoluteTime / NSTimeInterval → Date

This is what NSDate.timeIntervalSinceReferenceDate returns.

2) Date → CFAbsoluteTime / NSTimeInterval

Interpreted in your current local time zone.
If a zone/offset is provided, it will be respected.

About Apple Cocoa / Core Foundation Time

CFAbsoluteTime (also known as NSTimeInterval when used by NSDate) counts seconds— possibly fractional—since the Apple reference date 2001-01-01T00:00:00Z. This converter translates between that value and human-readable dates, preserving millisecond precision in outputs.

Compared to the UNIX epoch (1970-01-01T00:00:00Z), the Apple reference date occurs exactly 978,307,200 seconds later. Conversions are therefore:

  • CF → UNIX seconds: unix = cf + 978307200
  • UNIX seconds → CF: cf = unix - 978307200

CFAbsoluteTime Converter: FAQs

Do leap seconds or DST affect the number?

No. The stored value is an absolute UTC-based count of seconds. DST only affects how the time is displayed.

What about property lists (plists)?

Binary plists may store dates internally as CFAbsoluteTime. If you extract a raw number, paste it above—decimals allowed.

How much precision is kept?

Inputs accept fractional seconds. Results are shown to millisecond precision (ISO-8601 and local/UTC lines).

Apple Core Time: Code Snippets

Quick, copyable examples for converting between CFAbsoluteTime (a.k.a. NSTimeInterval, seconds since 2001-01-01T00:00:00Z) and human time. Exact offset to UNIX epoch (1970) is 978,307,200 seconds.

Swift

// CFAbsoluteTime ("since 2001") ↔ UNIX seconds ("since 1970")
let offset: TimeInterval = 978_307_200

func cfToUnix(_ cf: TimeInterval) -> TimeInterval {
    return cf + offset
}
func unixToCf(_ unix: TimeInterval) -> TimeInterval {
    return unix - offset
}

// CFAbsoluteTime ↔ Date
func cfToDate(_ cf: TimeInterval) -> Date {
    return Date(timeIntervalSince1970: cf + offset)
}
func dateToCf(_ date: Date) -> TimeInterval {
    return date.timeIntervalSince1970 - offset
}

// Examples
let cfNow: TimeInterval = Date.timeIntervalSinceReferenceDate
let dateFromCf = cfToDate(cfNow)
let cfFromDate = dateToCf(Date())

Objective-C

// CFAbsoluteTime ("since 2001") ↔ UNIX seconds
static const NSTimeInterval kOffset = 978307200.0;

NSTimeInterval CFToUnix(NSTimeInterval cf) {
    return cf + kOffset;
}
NSTimeInterval UnixToCF(NSTimeInterval unix) {
    return unix - kOffset;
}

// CFAbsoluteTime ↔ NSDate
NSDate * CFToDate(NSTimeInterval cf) {
    return [NSDate dateWithTimeIntervalSince1970:(cf + kOffset)];
}
NSTimeInterval DateToCF(NSDate *date) {
    return [date timeIntervalSince1970] - kOffset;
}

// Example
NSTimeInterval cfNow = [NSDate timeIntervalSinceReferenceDate];
NSDate *d = CFToDate(cfNow);

JavaScript (Browser / WebKit)

// CFAbsoluteTime ↔ UNIX seconds
const OFFSET = 978307200;

// CFAbsoluteTime (seconds) → Date
function cfToDate(cfSeconds) {
  return new Date((cfSeconds + OFFSET) * 1000);
}

// Date → CFAbsoluteTime (seconds, fractional)
function dateToCf(date) {
  return date.getTime() / 1000 - OFFSET;
}

// Example
const cfNow = dateToCf(new Date());
const dateFromCf = cfToDate(cfNow);

Python (macOS scripting, tooling)

OFFSET = 978_307_200  # seconds

def cf_to_unix(cf_seconds: float) -> float:
    return cf_seconds + OFFSET

def unix_to_cf(unix_seconds: float) -> float:
    return unix_seconds - OFFSET

def cf_to_datetime(cf_seconds: float):
    import datetime
    # returns aware UTC datetime
    return datetime.datetime.fromtimestamp(cf_seconds + OFFSET, tz=datetime.timezone.utc)

def datetime_to_cf(dt) -> float:
    import datetime, math
    if dt.tzinfo is None:
        # treat naive as local; convert to UTC for consistency
        dt = dt.astimezone()
    unix = dt.timestamp()  # seconds (float) since 1970 UTC
    return unix - OFFSET

# Example
# print(cf_to_datetime(0))  # 2001-01-01T00:00:00+00:00

Ruby (common in macOS automation)

OFFSET = 978_307_200.0

def cf_to_time(cf_seconds)
  Time.at(cf_seconds + OFFSET).utc
end

def time_to_cf(time_obj)
  time_obj.to_f - OFFSET
end

# Example:
# cf_to_time(0)      # => 2001-01-01 00:00:00 UTC
# time_to_cf(Time.now)

Handy Facts & Gotchas

  • NSDate reference: [NSDate timeIntervalSinceReferenceDate] returns CFAbsoluteTime.
  • Precision: CFAbsoluteTime is fractional seconds; most code above preserves millisecond precision.
  • DST/leap seconds: Values encode absolute UTC moments. DST only affects display format.
  • Plists: Binary plists may store dates internally as CFAbsoluteTime; when decoded, frameworks usually surface them as native dates.