DateFormatter date(from:) returns nil for date 2026-03-29 in Atlantic/Azores timezone

When using DateFormatter with the Atlantic/Azores timezone, calling date(from: formattedString) for the date 2026-03-29 returns nil unexpectedly.

codes:

    let dateFormatter = DateFormatter()
    dateFormatter.dateFormat = "yyyyMMdd" // 年月日格式
    dateFormatter.timeZone = TimeZone(identifier: "Atlantic/Azores")
    dateFormatter.locale = Locale(identifier: "en_US_POSIX")

    var now = Date()
    now -= 60 * 60 * 13
    let formattedString = dateFormatter.string(from: now)
    let dateWithTimeZone = dateFormatter.date(from: formattedString)
    print(formattedString) //20260329

    print(dateWithTimeZone) // nil
Answered by DTS Engineer in 882238022

It seems that Atlantic/Azores does its DST change at midnight, and hence you’re likely hitting the issue discussed in Parsing Dates Without Times.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

It seems that Atlantic/Azores does its DST change at midnight, and hence you’re likely hitting the issue discussed in Parsing Dates Without Times.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

DateFormatter date(from:) returns nil for date 2026-03-29 in Atlantic/Azores timezone
 
 
Q