0

I get timestamp results from database SQL query like 1465536311 or 1465540078. How to convert such number to current date and time in swift?

Chen Li Yong
  • 5,459
  • 8
  • 58
  • 124
  • 1
    http://stackoverflow.com/questions/7971807/nstimeinterval-to-nsdate – Bhavin Bhadani Jun 10 '16 at 09:56
  • @EICaptainv2.0 well, I don't know that was called `NSTimeInterval`. If it is, I also worried that the starting point to count the interval between SQL and iOS is different. So it wouldn't naturally occur to me to search for time interval conversion for this. – Chen Li Yong Jun 13 '16 at 02:01

1 Answers1

5

From NSDate Class Reference :

let date = NSDate(timeIntervalSince1970: 1465536311)
guidev
  • 2,695
  • 2
  • 23
  • 44
  • Thanks for the concise answer. Btw, I only can found the `timeIntervalSince1970` reference in NSDate class reference. Thanks! – Chen Li Yong Jun 13 '16 at 02:22