func getDateTime(_ timeStamp : String,_ format: String) -> String { var t1 = Int(timeStamp) ?? 1 t1 = t1/1000 let date = NSDate(timeIntervalSince1970: TimeInterval(t1)) let dateFormatter = DateFormatter() dateFormatter.dateFormat = format let dateString = dateFormatter.string(from: date as Date) print("Date = \(dateString)") return dateString }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter