---
title: "setLocalizedDateFormatFromTemplate(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/dateformatter/setlocalizeddateformatfromtemplate(_:)"
---

# setLocalizedDateFormatFromTemplate(_:)

Sets the date format from a template using the specified locale for the receiver.

## Declaration

```swift
func setLocalizedDateFormatFromTemplate(_ dateFormatTemplate: String)
```

## Parameters

- `dateFormatTemplate`: A string containing date format patterns (such as “MM” or “h”). For full details, see https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DatesAndTimes/DatesAndTimes.html#//apple_ref/doc/uid/10000039i.

## Discussion

Discussion See Data Formatting Guide for a list of the conversion specifiers permitted in date format strings. Calling this method is equivalent to, but not necessarily implemented as, setting the dateFormat property to the result of calling the dateFormat(fromTemplate:options:locale:) method, passing no options and the locale property value. important: You should call this method only after setting the locale of the receiver.

## See Also

### Related Documentation

- [locale](foundation/dateformatter/locale.md)

### Managing Formats and Styles

- [dateStyle](foundation/dateformatter/datestyle.md)
- [timeStyle](foundation/dateformatter/timestyle.md)
- [dateFormat](foundation/dateformatter/dateformat.md)
- [dateFormat(fromTemplate:options:locale:)](foundation/dateformatter/dateformat(fromtemplate:options:locale:).md)
- [formattingContext](foundation/dateformatter/formattingcontext.md)
