UNUserNotificationCenter.current().getPendingNotificationRequests { requests in
for request in requests {
let givenDate = request.trigger?.value(forKey: "dateComponents")
print(givenDate ?? "")
}
}
<NSDateComponents: 0x282884930> { Calendar Year: 2022 Month: 7 Day: 12 Hour: 12 Minute: 23
How can I convert this to a more readable format: "12 Jul 2022, 12:23 AM"?
NSDateComponentsis not aDate.As the name suggests, NSDateComponents has pieces of a date.if you want to convert it to a
Date(), you need to depend on a calendar.And then use a date formatted to format it as you want.