-1

I parsed the code "1442351280" from JSON and and I want to convert it to date in swift in medium style.

NoNaMe
  • 5,686
  • 30
  • 78
  • 104

2 Answers2

0

You have to this with with Foundation API

let date = NSDate(timeIntervalSince1970: 1442351280)
Girish Kolari
  • 2,485
  • 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
  • 69,532
  • 33
  • 158
  • 163