ios – DateFormatter dateStyle setting order causes problems?


let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss";
dateFormatter.timeZone = TimeZone.current;
dateFormatter.dateStyle = .none;
dateFormatter.timeStyle = .none;
let date = dateFormatter.date(from: "2023-08-03 00:00:00")

this date is nil, why ?

let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .none
dateFormatter.timeStyle = .none
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
dateFormatter.timeZone = TimeZone.current
let date = dateFormatter.date(from: "2023-08-03 00:00:00")

this date is correct

What causes this?I need help`

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img