iOS Get Unix Epoch time


Example

To get Unix Epoch Time, use the constant timeIntervalSince1970:

Swift

let date = NSDate() // current date
let unixtime = date.timeIntervalSince1970

Objective-C

NSDate *date = [NSDate date]; // current date
int unixtime = [date timeIntervalSince1970];