I parsed the code "1442351280" from JSON and and I want to convert it to date in swift in medium style.
Asked
Active
Viewed 63 times
-1
-
what happened when you attempted this? – Mitch Wheat Sep 21 '15 at 05:08
2 Answers
0
You have to this with with Foundation API
let date = NSDate(timeIntervalSince1970: 1442351280)

Girish Kolari
- 2,515
- 2
- 24
- 34
0
As mentioned into THIS post. It is a time-interval which you are getting from server.
And here is your answer:
var string : String = "1442351280"
var timeinterval : NSTimeInterval = (string as NSString).doubleValue
var dateFromServer = NSDate(timeIntervalSince1970:timeinterval)
print(dateFromServer) //"sep 16,2015, 2:38 AM"

Community
- 1
- 1

Dharmesh Kheni
- 71,228
- 33
- 160
- 165