---
title: "localizedString(from:unitsStyle:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/datecomponentsformatter/localizedstring(from:unitsstyle:)"
---

# localizedString(from:unitsStyle:)

Returns a localized string based on the specified date components and style option.

## Declaration

```swift
class func localizedString(from components: DateComponents, unitsStyle: DateComponentsFormatter.UnitsStyle) -> String?
```

## Parameters

- `components`: The value to format.
- `unitsStyle`: The style for the resulting units. Use this parameter to specify whether you want to the resulting string to use an abbreviated or more spelled out format.

## Return Value

Return Value A string containing the localized date and time information.

## Discussion

Discussion Use this convenience method to format a string using the default formatter values, with the exception of the unitsStyle value.

## See Also

### Formatting Values

- [string(from:)](foundation/datecomponentsformatter/string(from:)-9exxn.md)
- [string(for:)](foundation/datecomponentsformatter/string(for:).md)
- [string(from:to:)](foundation/datecomponentsformatter/string(from:to:).md)
- [string(from:)](foundation/datecomponentsformatter/string(from:)-7sj4j.md)
