<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/DateFormatter/setLocalizedDateFormatFromTemplate(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDateFormatter(im)setLocalizedDateFormatFromTemplate:"
  },
  "title" : "setLocalizedDateFormatFromTemplate(_:)"
}
-->

# setLocalizedDateFormatFromTemplate(_:)

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

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

## Parameters

`dateFormatTemplate`

A string containing date format patterns (such as “MM” or “h”).

    For full details, see     [Date and Time Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DatesAndTimes/DatesAndTimes.html#//apple_ref/doc/uid/10000039i)    .

## Discussion

See [Data Formatting Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DataFormatting/DataFormatting.html#//apple_ref/doc/uid/10000029i) 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`](/documentation/Foundation/DateFormatter/dateFormat) property to the result of calling the [`dateFormat(fromTemplate:options:locale:)`](/documentation/Foundation/DateFormatter/dateFormat(fromTemplate:options:locale:)) method, passing no options and the [`locale`](/documentation/Foundation/DateFormatter/locale) property value.

> Important:
> You should call this method only after setting the ``doc://com.apple.foundation/documentation/Foundation/DateFormatter/locale`` of the receiver.

## See Also

[`locale`](/documentation/Foundation/DateFormatter/locale)

The locale for the receiver.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)