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(from: self)
}
}You can call the above function to be like below.
myDate.getMonthName()
Comments
Post a Comment