Convert Mac HFS+ timestamp (seconds since 1904) to human-readable date
This script converts Apple Mac OS X HFS+ timestamps to normal dates. An HFS Plus-timestamp is the number of seconds since midnight, January 1, 1904, GMT. These timestamps are also used by Apple iPod's, Palm OS, JMP/JSL datetime and others.
Mac HFS+ to Unix
Unix to Mac HFS+
Programming Examples
The difference between the Unix timestamp epoch (1970) and the Mac timestamp epoch (1904) is 2082844800 seconds.
Learn how to convert Mac HFS+ timestamps in Swift and Objective-C:
import Foundation
// Mac HFS+ epoch: January 1, 1904 00:00:00 UTC
let HFS_EPOCH: TimeInterval = 2082844800
// Convert Mac HFS+ timestamp to Date
func macHFSToDate(_ macTimestamp: TimeInterval) -> Date {
let unixSeconds = macTimestamp - HFS_EPOCH
return Date(timeIntervalSince1970: unixSeconds)
}
// Convert Date to Mac HFS+ timestamp
func dateToMacHFS(_ date: Date) -> TimeInterval {
let unixSeconds = date.timeIntervalSince1970
return unixSeconds + HFS_EPOCH
}
// Example usage
let macTimestamp: TimeInterval = 3851934862
let date = macHFSToDate(macTimestamp)
print(date)
let now = Date()
let macTs = dateToMacHFS(now)
print("Mac HFS+ timestamp: \(macTs)")
// Current timestamp in Swift
let currentTimestamp = HFS_EPOCH + Date().timeIntervalSince1970
print("Current Mac timestamp: \(currentTimestamp)")Swift uses TimeInterval (Double) for time calculations. The Mac HFS+ epoch is 1904, which is 2082844800 seconds before Unix epoch (1970).
What is Mac HFS+ Timestamp?
Mac HFS+ (Hierarchical File System Plus) uses a timestamp format that counts seconds since January 1, 1904, 00:00:00 UTC. This was the epoch used by classic Mac OS and is still used in some legacy Mac file systems. Unlike Unix timestamps which use January 1, 1970 as the epoch, Mac HFS+ timestamps use an earlier epoch date, making them larger numbers. This format is commonly found in legacy Mac systems, Apple iPod timestamps, and Palm OS datetime values.
Conversion formula:
- Mac HFS+ to Unix:
unix = hfs - 2082844800 - Unix to Mac HFS+:
hfs = unix + 2082844800
Note: To convert seconds since 2001, see: Cocoa Core Data Timestamp (or 'Mac absolute time').
Use cases: Legacy Mac file system analysis, classic Mac OS compatibility, historical timestamp conversion, Apple iPod timestamps, Palm OS datetime, and converting timestamps from legacy Mac systems for modern applications. This tool is essential for developers working with legacy Mac data or file system forensics.
Frequently Asked Questions
What is a Mac HFS+ timestamp?
Mac HFS+ (Hierarchical File System Plus) uses a timestamp format that counts seconds since January 1, 1904, 00:00:00 UTC. This was the epoch used by classic Mac OS and is still used in some legacy Mac file systems.
How do I convert a Mac HFS+ timestamp to Unix timestamp?
Enter your Mac HFS+ timestamp in the input field and click convert. The tool will automatically convert it to a Unix timestamp and display the human-readable date. Mac HFS+ timestamps are larger numbers than Unix timestamps because they use an earlier epoch date.
What is the difference between Mac HFS+ and Cocoa timestamps?
Mac HFS+ timestamps use January 1, 1904 as the epoch, while Cocoa timestamps use January 1, 2001. Mac HFS+ is used by legacy Mac file systems, while Cocoa is used by modern macOS/iOS Core Data. They are different timestamp formats for different purposes.