toString(dateStyle: DateFormatter.Style = default, timeStyle: DateFormatter.Style = default, locale: Locale = default) -> String

Return the string representation for a date.

Parameters

  • dateStyle: A DateFormatter.Style for the date. default to .medium.
  • timeStyle: A DateFormatter.Style for the time. default to .medium.
  • locale: Locale for the string. Default to the current locale.

Returns

The date string.

let date = Date()
date.toString(dateStyle: .short, timeStyle: .short)
// -> "30/12/2016, 14:34"