Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Unix Epoch Time in Swift

Tags:

time

swift

How do you get the seconds from epoch in Swift?

like image 852
Chris Redford Avatar asked Aug 02 '14 15:08

Chris Redford


People also ask

How do I get epoch time in Swift?

You can simply use NSDate's timeIntervalSince1970 function. Note this needs to have Foundation imported.

What is epoch format?

In a computing context, an epoch is the date and time relative to which a computer's clock and timestamp values are determined. The epoch traditionally corresponds to 0 hours, 0 minutes, and 0 seconds (00:00:00) Coordinated Universal Time (UTC) on a specific date, which varies from system to system.


1 Answers

You can simply use NSDate's timeIntervalSince1970 function.

let timeInterval = NSDate().timeIntervalSince1970 
like image 81
Yannik Avatar answered Sep 27 '22 19:09

Yannik