iOS NSDate Get Unix Epoch time

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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];


Got any iOS Question?