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

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift