Posts

Showing posts with the label date

DateFomatter in Swift

Image
Apple Says A formatter that converts between dates and their textual representations. In simple word It is a class that can take a Date, and output a String describing that time/date as its format instructions dictate. In other words, it has a few pretty useful built-in formats, and the capability to accept a custom date format string. It helps to convert date to string and also helps from string to date Example of Date to String let date : Date = Date () let dateFormatter = DateFormatter () dateFormatter . dateFormat = "MM/dd/yyyy" let todaysDate = dateFormatter . string ( from : date ) //Output will be 05/04/2019 Example of String to Date let dateFormatter = DateFormatter () dateFormatter . dateFormat = "MM/dd/yyyy" let dateObj = dateFormatter . dateFromString ( "05/04/2019" ) More formatter Sunday , Apr 07 , 2019 --> EEEE , MMM d , yyyy 07 / 04 / 2019 -...