<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Calendar/Component",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation8CalendarV9ComponentO"
  },
  "title" : "Calendar.Component"
}
-->

# Calendar.Component

An enumeration for the various components of a calendar date.

```
enum Component
```

## Overview

You use one or more [`Calendar.Component`](/documentation/Foundation/Calendar/Component) values with the [`component(_:from:)`](/documentation/Foundation/Calendar/component(_:from:)) or [`dateComponents(_:from:)`](/documentation/Foundation/Calendar/dateComponents(_:from:)) methods to specify parts to extract from a given [`Date`](/documentation/Foundation/Date).

The following code listing shows how to use the year, month, and day components to get the corresponding units of the current Gregorian calendar date as a [`DateComponents`](/documentation/Foundation/DateComponents) instance.

```swift
let myCalendar = Calendar(identifier: .gregorian)
let ymd = myCalendar.dateComponents([.year, .month, .day], from: Date())
```

## Topics

### Specifying Years and Months

[`Calendar.Component.era`](/documentation/Foundation/Calendar/Component/era)

Identifier for the era unit.

[`Calendar.Component.year`](/documentation/Foundation/Calendar/Component/year)

Identifier for the year unit.

[`Calendar.Component.yearForWeekOfYear`](/documentation/Foundation/Calendar/Component/yearForWeekOfYear)

Identifier for the week-counting year unit.

[`Calendar.Component.quarter`](/documentation/Foundation/Calendar/Component/quarter)

Identifier for the quarter of the calendar.

[`Calendar.Component.month`](/documentation/Foundation/Calendar/Component/month)

Identifier for the month unit.

### Specifying Weeks and Days

[`Calendar.Component.weekOfYear`](/documentation/Foundation/Calendar/Component/weekOfYear)

Identifier for the week of the year unit.

[`Calendar.Component.weekOfMonth`](/documentation/Foundation/Calendar/Component/weekOfMonth)

Identifier for the week of the month calendar unit.

[`Calendar.Component.weekday`](/documentation/Foundation/Calendar/Component/weekday)

Identifier for the weekday unit.

[`Calendar.Component.weekdayOrdinal`](/documentation/Foundation/Calendar/Component/weekdayOrdinal)

Identifier for the weekday ordinal unit.

[`Calendar.Component.day`](/documentation/Foundation/Calendar/Component/day)

Identifier for the day unit.

### Specifying Hours, Minutes, and Seconds

[`Calendar.Component.hour`](/documentation/Foundation/Calendar/Component/hour)

Identifier for the hour unit.

[`Calendar.Component.minute`](/documentation/Foundation/Calendar/Component/minute)

Identifier for the minute unit.

[`Calendar.Component.second`](/documentation/Foundation/Calendar/Component/second)

Identifier for the second unit.

[`Calendar.Component.nanosecond`](/documentation/Foundation/Calendar/Component/nanosecond)

Identifier for the nanosecond unit.

### Specifying Calendars and Time Zones

[`Calendar.Component.calendar`](/documentation/Foundation/Calendar/Component/calendar)

Identifier for the calendar unit.

[`Calendar.Component.timeZone`](/documentation/Foundation/Calendar/Component/timeZone)

Identifier for the time zone unit.



---

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)
