Get the day Name from date iOS swift
Problem:
I want to get the dayname from date.How to get thet?
Solution:
extension Date {
func getDayName() -> String {
let dateFormatter = DateFormatter()
dateFormatter.timeZone = NSTimeZone.local
dateFormatter.dateFormat = "EEEE" // "EE" to get short style
let dayInWeek = dateFormatter.string(from: self) // "Sunday"
return dayInWeek
}
}
Comments
Post a Comment