---
title: "hour(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/date/formatstyle/hour(_:)"
---

# hour(_:)

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

## Declaration

```swift
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

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

## Discussion

Discussion Values of Date.FormatStyle.Symbol.Hour are defaultDigitsNoAMPM and twoDigitsNoAMPM. Static methods that return Date.FormatStyle.Symbol.Hour objects include conversationalDefaultDigits(amPM:), conversationalTwoDigits(amPM:), defaultDigits(amPM:), and twoDigitsNoAMPM. This example shows a variety of Date.FormatStyle.Symbol.Hour format styles applied to a date: 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 static variable is the default format. For more information about formatting dates, see Date.FormatStyle.

## See Also

### Specifying the Time Format

- [minute(_:)](foundation/date/formatstyle/minute(_:).md)
- [second(_:)](foundation/date/formatstyle/second(_:).md)
- [secondFraction(_:)](foundation/date/formatstyle/secondfraction(_:).md)
- [timeZone(_:)](foundation/date/formatstyle/timezone(_:).md)
- [Date.FormatStyle.TimeStyle](foundation/date/formatstyle/timestyle.md)
