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

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift