<!--
{
  "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/Symbol/Hour",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation4DateV11FormatStyleV6SymbolV4HourV"
  },
  "title" : "Date.FormatStyle.Symbol.Hour"
}
-->

# Date.FormatStyle.Symbol.Hour

A type that specifies a format for the hour in a date format style.

```
struct Hour
```

## Overview

The type [`Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour) includes static factory variables and methods that create custom [`Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour) objects:

|Factory variable                                                                                                       |Description                                                                                                                                                                                                                                                   |
|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|``doc://com.apple.foundation/documentation/Foundation/Date/FormatStyle/Symbol/Hour/defaultDigitsNoAMPM``               |The minimum number of digits that represents the full numeric hour. This doesn’t include the day period (a.m. or p.m.). For example, `1`, `11`.                                                                                                               |
|``doc://com.apple.foundation/documentation/Foundation/Date/FormatStyle/Symbol/Hour/twoDigitsNoAMPM``                   |Two-digit numeric hour, zero-padded if necessary. This doesn’t include the day period (a.m. or p.m.). For example, `01`, `11`.                                                                                                                                |
|``doc://com.apple.foundation/documentation/Foundation/Date/FormatStyle/Symbol/Hour/defaultDigits(amPM:)``              |The minimum number of digits that represents the full numeric hour. This may include the day period (a.m. or p.m.), depending on locale. For example, `7a` (`narrow`), `7AM` (`abbreviated`), `7A.M.` (`wide`).                                               |
|``doc://com.apple.foundation/documentation/Foundation/Date/FormatStyle/Symbol/Hour/twoDigits(amPM:)``                  |Two-digit numeric hour, zero-padded if necessary. This may include the day period (a.m. or p.m.), depending on locale. For example, `07a` (`narrow`), `07AM` (`abbreviated`), `07A.M.` (`wide`).                                                              |
|``doc://com.apple.foundation/documentation/Foundation/Date/FormatStyle/Symbol/Hour/conversationalDefaultDigits(amPM:)``|The minimum number of digits that represents the full numeric hour. This may include the day period (a.m. or p.m.), depending on locale, and can include conversational period formats. For example, `7a` (`narrow`), `7AM` (`abbreviated`), `7A.M.` (`wide`).|
|``doc://com.apple.foundation/documentation/Foundation/Date/FormatStyle/Symbol/Hour/conversationalTwoDigits(amPM:)``    |Two-digit numeric hour, zero-padded if necessary. This may include the day period (a.m. or p.m.), depending on locale, and can include conversational period formats. For example, `07a` (`narrow`), `07AM` (`abbreviated`), `07A.M.` (`wide`).               |

To customize the hour format in a string representation of a `Date`, use [`hour(_:)`](/documentation/Foundation/Date/FormatStyle/hour(_:)) The example below 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 no format is specified as a parameter, the [`defaultDigits`](/documentation/Foundation/Date/FormatStyle/Symbol/Minute/defaultDigits) static variable is the default format.

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

## Topics

### Modifying an Hour

[`static var defaultDigitsNoAMPM: Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/defaultDigitsNoAMPM)

Custom format style portraying the minimum number of digits that represents the numeric hour.

[`static var twoDigitsNoAMPM: Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/twoDigitsNoAMPM)

Custom format style portraying the numeric hour using two digits.

[`static func conversationalDefaultDigits(amPM: Date.FormatStyle.Symbol.Hour.AMPMStyle) -> Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/conversationalDefaultDigits(amPM:))

Custom format style portraying the minimum number of digits that represents the hour and locale-dependent conversational day period formats.

[`static func conversationalTwoDigits(amPM: Date.FormatStyle.Symbol.Hour.AMPMStyle) -> Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/conversationalTwoDigits(amPM:))

Custom format style portraying two digits that represent the hour and locale-dependent conversational day period formats.

[`static func defaultDigits(amPM: Date.FormatStyle.Symbol.Hour.AMPMStyle) -> Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/defaultDigits(amPM:))

Custom format style portraying the minimum number of digits that represents the hour and locale-dependent day period formats.

[`static func twoDigits(amPM: Date.FormatStyle.Symbol.Hour.AMPMStyle) -> Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/twoDigits(amPM:))

Custom format style portraying two digits that represent the hour and locale-dependent day period formats.

### Supporting Structures

[`struct AMPMStyle`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/AMPMStyle)

The format style of the string representation of the day period, before or after noon, in a date.

### Comparing an Hour

[`static func == (Date, Date) -> Bool`](/documentation/Foundation/Date/==(_:_:))

Returns true if the two `Date` values represent the same point in time.

### Type Properties

[`static let omitted: Date.FormatStyle.Symbol.Hour`](/documentation/Foundation/Date/FormatStyle/Symbol/Hour/omitted)

The option for not including the symbol in the formatted output.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

---

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)