-1

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

NoNaMe
  • 6,020
  • 30
  • 82
  • 110

2 Answers2

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