Answers for "save date to userdefaults swift"


save date to userdefaults swift

//save as Date
UserDefaults.standard.set(Date(), forKey: key)

let date = UserDefaults.standard.object(forKey: key) as! Date
let df = DateFormatter()
df.dateFormat = "dd/MM/yyyy HH:mm"
print(df.string(from: date))
Posted by: Guest on April-03-2020

Code answers related to "save date to userdefaults swift"

Code answers related to "Swift"

Browse Popular Code Answers by Language