<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSCalendar/date(era:year:month:day:hour:minute:second:nanosecond:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCalendar(im)dateWithEra:year:month:day:hour:minute:second:nanosecond:"
  },
  "title" : "date(era:year:month:day:hour:minute:second:nanosecond:)"
}
-->

# date(era:year:month:day:hour:minute:second:nanosecond:)

Returns a date created with the given components.

```
func date(era eraValue: Int, year yearValue: Int, month monthValue: Int, day dayValue: Int, hour hourValue: Int, minute minuteValue: Int, second secondValue: Int, nanosecond nanosecondValue: Int) -> Date?
```

## Parameters

`eraValue`

The value to set for the era.

`yearValue`

The value to set for the year.

`monthValue`

The value to set for the month.

`dayValue`

The value to set for the day.

`hourValue`

The value to set for the hour.

`minuteValue`

The value to set for the minute.

`secondValue`

The value to set for the second.

`nanosecondValue`

The value to set for the nanosecond.

## Return Value

A new `NSDate` instance created with the given components, or `nil` if the components do not correspond to a valid date.

---

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)