---
title: "format(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/duration/unitsformatstyle/attributed-swift.struct/format(_:)"
---

# format(_:)

Creates a locale-aware attributed string representation from a duration value.

## Declaration

```swift
func format(_ duration: Duration) -> AttributedString
```

## Parameters

- `duration`: The duration value to format.

## Return Value

Return Value A string representation of the duration, according to the style’s pattern and locale.

## Discussion

Discussion Use this method when you want to create a format style and repeatedly use it to format different durations. For one-off cases with default formatting, call the formatted() method of Duration instead.
