Check out example codes for "save date to userdefaults swift". It will help you in understanding the concepts better.

Code Example 1

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

//read
let date = UserDefaults.standard.object(forKey: key) as! Date
let df = DateFormatter()
df.dateFormat = "dd/MM/yyyy HH:mm"
print(df.string(from: date))

Learn ReactJs, React Native from akashmittal.com