DateFormatter parses the date correctly when using the default timezone in iPhone settings. However, if I change to any custom TimeZone, DateFormatter returns nil.
Here is the code snippet
extension String{
func toDate() -> Date?{
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd-MMM-yyyy hh:mm a"
let date = dateFormatter.date(from:self)
return date ?? nil
}
}
If I use the default time zone settings in iPhone Settings, it works. However, if I change the time zone to a custom one and switch to a 24-hour format, DateFormatter returns nil.
Sample screenshot attached for the time zone settings.
Post
Replies
Boosts
Views
Activity
On first installation of the sample app of iMessage Extension from apple
the app icon visible, but after I uninstalled it and again installed the app, the app icon is not visible. Here is the screenshot and the apple sample app.
https://developer.apple.com/documentation/messages/icecreambuilder-building-an-imessage-extension