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

    date

    The date you want the string of

    dateFormat

    The 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

    dateString

    Date stirng to convert.

    format

    Date String format.

    timeZone

    time 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) -> String

    Parameters

    date

    Date to convert.

    format

    Date String format.

    timeZone

    time zone of the date to be converted.

    Return Value

    Date string converted from date.