DateFormatter
class DateFormatter : Formatter
Collection of all DateFormatter Extensions.
Subspec: Extensions/DateFormatterExtension
-
Single Instance of DateFormatter for the App.
Declaration
Swift
private static let sharedInstance: DateFormatter -
Uses a static formatter to build you a string from a format, don’t use it though, go to Date Extensions and use that instead.
Declaration
Swift
static func string(of date: Date, using dateFormat: String) -> String?Parameters
dateThe date you want the string of
dateFormatThe format you want it in.
Return Value
The string.
-
Converts the given date string to the date in the specific format string and time zone.
Declaration
Swift
static func date(from dateString: String, format: String, timeZone: TimeZone = .current) -> Date?Parameters
dateStringDate stirng to convert.
formatDate String format.
timeZonetime zone of the date to be converted.
Return Value
Converted Date.
-
Converts the given date to the date string in the specific format and time zone.
Declaration
Swift
static func dateString(from date: Date, format: String, timeZone: TimeZone = .current) -> StringParameters
dateDate to convert.
formatDate String format.
timeZonetime zone of the date to be converted.
Return Value
Date string converted from date.
DateFormatter Extension Reference