0

I want to print the date as December 2022 but this way printing Wednesday, 07 Sep. How do I edit the code below so that it prints "Mont, Year"? Like this "September, 2022"

func getDayMonDateFormat() -> String {
        let dateFormatter = DateFormatter()//EEEE, d, MMM
        dateFormatter.dateFormat = "yyyy-MM-dd' 'HH:mm:ss"
        dateFormatter.timeZone = TimeZone.current
        dateFormatter.locale = Locale.current
        guard let oldDate = dateFormatter.date(from: self) else { return "" }
        let convertDateFormatter = DateFormatter()
        convertDateFormatter.dateFormat = "EEEE, dd MMM"
        
        return convertDateFormatter.string(from: oldDate)
    }
Ezgi Özkan
  • 111
  • 5
  • Actually you have all necessary date symbols in your code. `y` is year and `M` is month, four `M` is the full name. Please see https://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns for the whole list. – vadian Sep 05 '22 at 17:10
  • `"EEEE, dd MMM"` That's the output format you wrote. What does it mean to you? Why did you write theses specific letters/placeholders? – Larme Sep 05 '22 at 17:11

0 Answers0