Contents

localizedString(from:dateStyle:timeStyle:)

Returns a string representation of a specified date, that the system formats for the current locale using the specified date and time styles.

Declaration

class func localizedString(from date: Date, dateStyle dstyle: DateFormatter.Style, timeStyle tstyle: DateFormatter.Style) -> String

Parameters

  • date:

    A date.

  • dstyle:

    A format style for the date. For possible values, see Style.

  • tstyle:

    A format style for the time. For possible values, see Style.

Return Value

A localized string representation of date using the specified date and time styles.

Discussion

This method uses a date formatter configured with the current default settings. The returned string is the same as if you configured and used a date formatter as shown in the following example:

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.formatterBehavior = NSDateFormatterBehavior10_4;
formatter.dateStyle = dateStyle;
formatter.timeStyle = timeStyle;
NSString *result = [formatter stringForObjectValue:date];

See Also

Converting Objects