Avatar
@swift-5.7.3 import Foundation var f = DateFormatter() f.dateFormat = "yyyy/MM/dd HH:mm:ss" f.locale = Locale(identifier: "ja") f.calendar = .init(identifier: .gregorian) f.timeZone = TimeZone(abbreviation: "JST")! print(f.date(from: "2022/07/10 12:00:00") ?? "nil") // ok print(f.date(from: "2022-07-10 12:00:00") ?? "nil") // macだとok, Linuxだとng (edited)