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

How to blink a button iOS swift?

Convert NsNumber, NSDate to String in iOS Swift

Parse the value from string value iOS swift