let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
let localeIdentifier = "ar_AE"
dateFormatter.locale = Locale(identifier: localeIdentifier)
if let date = dateFormatter.date(from: "2022-12-26") {
dateFormatter.dateFormat = "dd MMM YYYY"
let displayDate = dateFormatter.string(from: date)
print(displayDate) // "26 ديسمبر 2023"
}
Converted date is one year ahead of the actual date. This issue occurs only with specific dates ranging from 26-Dec-2022 to 31st-Dec-2022, when Arabic locale is selected and on IOS 16.0 and above devices.
5
0
3.5k