toString(format: String, locale: Locale = default) -> String

Return the string representation for a date.

Parameters

  • format: A date format string.
  • locale: Locale for the string. Default to the current locale.

Returns

The date string.

let date = Date()
date.toString(format: "MMM yyyy")
// -> "Dec 2016"