<!--
{
  "availability" : [
    "iOS: 2.0.0 - 8.0.0",
    "iPadOS: 2.0.0 - 8.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.4.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSDate/date(withCalendarFormat:timeZone:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDate(im)dateWithCalendarFormat:timeZone:"
  },
  "title" : "date(withCalendarFormat:timeZone:)"
}
-->

# date(withCalendarFormat:timeZone:)

Converts the receiver to a calendar date with a given format string and time zone.

```
func date(withCalendarFormat format: String?, timeZone aTimeZone: TimeZone?) -> NSCalendarDate
```

## Parameters

`format`

The format for the returned string (see Date and Number Formatters in OS X v10.0 to 10.3 for a discussion of how to create the format string). Pass `nil` to use the default format string, “`%Y-%m-%d %H:%M:%S %z`” (this conforms to the international format `YYYY-MM-DD HH:MM:SS ±HHMM`.)

`aTimeZone`

The time zone for the new calendar date. Pass `nil` to use the default time zone—specific to the current locale.

## Return Value

A new [`NSCalendarDate`](/documentation/Foundation/NSCalendarDate) object bound to `format` and the time zone `aTimeZone`.

---

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)