How to convert Unix timestamp into Swift NSDate object?

dead_man picture dead_man · Nov 10, 2014 · Viewed 19.5k times · Source

I'm getting dates as Unix timestamps through my API and I want to convert them into NSDate objects in Swift.

How can I do that?

Answer

Marcos Crispino picture Marcos Crispino · Nov 10, 2014

Try this:

var date = NSDate(timeIntervalSince1970: timeInterval)