Skip to content

Instantly share code, notes, and snippets.

@PetreVane
Created November 18, 2019 14:27
Show Gist options
  • Save PetreVane/30fb39edb58b54534312b12618a17b50 to your computer and use it in GitHub Desktop.
Save PetreVane/30fb39edb58b54534312b12618a17b50 to your computer and use it in GitHub Desktop.
Decodes Unix time in Time that has a significance
func decodeDatefrom(_ unixTime: String) -> String? {
// converts comment date into meaningful date
var decodedDate: String?
if let unixTime = Double(unixTime) {
let dateFormatter = DateFormatter()
let date = Date(timeIntervalSince1970: unixTime)
dateFormatter.dateFormat = "dd.MM.yyyy"
decodedDate = dateFormatter.string(from: date)
}
return decodedDate
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment