Convert TimeStamp to date and time

PHOTO EMBED

Wed Jan 19 2022 06:07:29 GMT+0000 (UTC)

Saved by @hasnat #ios #swift #timestamp #date #time

let timeStamp = Date().timeIntervalSince1970
let date = NSDate(timeIntervalSince1970: timeStamp)
let dayTimePeriodFormatter = DateFormatter()
dayTimePeriodFormatter.dateFormat = "dd MMMM,yyyy.hh:mm a"
let dateTimeString = dayTimePeriodFormatter.string(from: date as Date)
let dateTime = dateTimeString.split(separator: ".")
print( "Date = \(dateTime[0])")
print( "Time = \(dateTime[1])")
content_copyCOPY