---
title: "format(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/date/relativeformatstyle/format(_:)"
---

# format(_:)

Creates a locale-aware string representation from a relative date value.

## Declaration

```swift
func format(_ destDate: Date) -> String
```

## Parameters

- `destDate`: The date to format.

## Return Value

Return Value A string representation of the relative date.

## Discussion

Discussion The format(_:) instance method generates a string from the provided relative date. Once you create a style, you can use it to format dates multiple times. The following example applies a format style repeatedly to produce string representations of relative dates: if let pastWeek = Calendar.current.date(byAdding: .day, value: -7, to: Date()) {     if let pastDay = Calendar.current.date(byAdding: .day, value: -1, to: Date()) {

let formatStyle = Date.RelativeFormatStyle(             presentation: .named,             unitsStyle: .spellOut,             locale: Locale(identifier: "en_GB"),             calendar: Calendar.current,             capitalizationContext: .beginningOfSentence)                  formatStyle.format(pastDay) // "Yesterday"         formatStyle.format(pastWeek) // "Last week"     } }
