DateFormatter outputting wrong date on the 1st of Feb 2023

The following code: 

let start_time = (NSDate().timeIntervalSince1970)

let GET_start_acq_time = NSDate(timeIntervalSince1970: Double(start_time))

let formatter = DateFormatter()

formatter.locale = NSLocale.current

formatter.dateFormat = "YYYY-MM-DD HH:mm:ss:SSS"

let GET_start_acq_time_string = formatter.string(from: GET_start_acq_time as Date)

print("Today's date = (GET_start_acq_time_string)")

output this date Today:

Today's date = 2023-02-32 10:26:39:965

Yesterday was fine.

Have fun with it, it is simple to reproduce, it's on IOS latest Xcode

The bug is in your format string: DD means day of the year. You want dd which means day of the month.

Also, there’s a subtle difference between YYYY and yyyy in some cases; see the Unicode spec linked from here.

Thank you good eye! I miss that.

DateFormatter outputting wrong date on the 1st of Feb 2023
 
 
Q