I have a DateComponents object that contains a month and a year and I'd like to have a formatted string from it in the style 'March 2021'. I've tried DateComponentsFormatter but none of the properties get anywhere near what I'd like to see.
let components = DateComponents(calendar: .current, timeZone: .current, year: 2021, month: 3, day: nil)
let formatter = DateComponentsFormatter()
let string = formatter.string(from: components) // Optional("2,021y 3mo")
Is this possible to do from DateComponents please?
It's pretty much something like this you need to do
https://nsdateformatter.com/ here you can see how to format the dates in different ways.