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

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift