<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Date/FormatStyle/hour(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation4DateV11FormatStyleV4houryA2E6SymbolV4HourVF"
  },
  "title" : "hour(_:)"
}
-->

# hour(_:)

Modifies the date format style to use the specified hour format style.

```
func hour(_ format: Date.FormatStyle.Symbol.Hour = .defaultDigits(amPM: .abbreviated)) -> Date.FormatStyle
```

## Parameters

`format`

The hour format style applied to the date format style.

## Return Value

A date format style modified to include the specified hour style.

## Discussion

Values of [`Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour) are [`defaultDigitsNoAMPM`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/defaultDigitsNoAMPM) and [`twoDigitsNoAMPM`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/twoDigitsNoAMPM).

Static methods that return [`Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour) objects include [`conversationalDefaultDigits(amPM:)`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/conversationalDefaultDigits(amPM:)), [`conversationalTwoDigits(amPM:)`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/conversationalTwoDigits(amPM:)), [`defaultDigits(amPM:)`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/defaultDigits(amPM:)), and [`twoDigitsNoAMPM`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/twoDigitsNoAMPM).

This example shows a variety of [`Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour) format styles applied to a date:

```swift
let meetingDate = Date() // Feb 9, 2021 at 7:00 PM
meetingDate.formatted(Date.FormatStyle().hour(.defaultDigitsNoAMPM)) 
// 7

meetingDate.formatted(Date.FormatStyle().hour(.twoDigitsNoAMPM)) 
// 07

meetingDate.formatted(Date.FormatStyle().hour(.defaultDigits(amPM: .narrow))) 
// 7p

meetingDate.formatted(Date.FormatStyle().hour(.twoDigits(amPM: .abbreviated))
// 07 PM

meetingDate.formatted(Date.FormatStyle().hour(.conversationalDefaultDigits(amPM: .wide))
// 7 P.M.
```

If you don’t provide a format, the [`defaultDigits`](/documentation/Foundation/Date/FormatStyle/Symbol/Minute/defaultDigits) static variable is the default format.

For more information about formatting dates, see [`Date.FormatStyle`](/documentation/Foundation/Date/FormatStyle).

---

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)