Get the monthname from one date iOS swift

 Problem:

I want one function that will return the month name like september. I'm having date with me.How to achieve that.


Solution:

extension Date {

    // MARK: - Get month Name

    func getMonthName() -> String {

        let format = DateFormatter()

        format.dateFormat = "MMMM"

        return format.string(fromself)

    }

}

You can call the above function to be like below.

myDate.getMonthName()

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift