<!--
{
  "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/getEra(_:year:month:day:from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCalendar(im)getEra:year:month:day:fromDate:"
  },
  "title" : "getEra(_:year:month:day:from:)"
}
-->

# getEra(_:year:month:day:from:)

Returns by reference the era, year, week of year, and weekday component values for a given date.

```
func getEra(_ eraValuePointer: UnsafeMutablePointer<Int>?, year yearValuePointer: UnsafeMutablePointer<Int>?, month monthValuePointer: UnsafeMutablePointer<Int>?, day dayValuePointer: UnsafeMutablePointer<Int>?, from date: Date)
```

## Parameters

`eraValuePointer`

Upon return, contains the era of the given date.

`yearValuePointer`

Upon return, contains the year of the given date.

`monthValuePointer`

Upon return, contains the month of the given date.

`dayValuePointer`

Upon return, contains the day of the given date.

`date`

The date for which to perform the calculation.

## Discussion

Pass `NULL` to ignore any individual component parameter.

This is a convenience method for getting the time components of a given date using [`components(_:from:)`](/documentation/Foundation/NSCalendar/components(_:from:))

---

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)