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

store cgpoint in userdefaults iOS swift

libc++abi: terminating due to uncaught exception of type NSException iOS swift