Dateformatter returns date in incorrect format

I have configured DateFormatter in the following way:

let df = DateFormatter()
df.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
df.locale = .init(identifier: "en")
df.timeZone = .init(secondsFromGMT: 0)

in some user devices instead of ISO8601 style it returns date like 09/25/2024 12:00:34

Tried to change date format from settings, changed calendar and I think that checked everything that can cause the problem, but nothing helped to reproduce this issue, but actually this issue exists and consumers complain about not working date picker. Is there any information what can cause such problem? May be there is some bug in iOS itself?

Answered by Scott in 825873022

Search the forum for “fixed format dates” and you’ll get a few hits explaining the issue and a couple ways to fix it.

Among the available solutions, I recommend just switching to ISO8601DateFormatter instead of trying to use the original localization-focused DateFormatter.

Search the forum for “fixed format dates” and you’ll get a few hits explaining the issue and a couple ways to fix it.

Among the available solutions, I recommend just switching to ISO8601DateFormatter instead of trying to use the original localization-focused DateFormatter.

Dateformatter returns date in incorrect format
 
 
Q