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

# hour(_:)

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

## Declaration

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

## Parameters

- `format`: The hour format style to apply to the date interval format style.

## Return Value

Return Value A date interval format style that includes the specified hour style.

## Discussion

Discussion The values of Date.FormatStyle.Symbol.Hour are defaultDigitsNoAMPM and twoDigitsNoAMPM. The static methods that return Date.FormatStyle.Symbol.Hour objects include conversationalDefaultDigits(amPM:), conversationalTwoDigits(amPM:), and defaultDigits(amPM:). This example shows a variety of Date.FormatStyle.Symbol.Hour format styles for a date interval: if let today = Calendar.current.date(byAdding: .day, value: -140, to: Date()),    let sevenDaysBeforeToday = Calendar.current.date(byAdding: .day, value: -7, to: today) {

// Create a Range<Date>.     let weekBefore = sevenDaysBeforeToday..<today

print(weekBefore.formatted(.interval.minute()))     print(weekBefore.formatted(.interval.day().minute().hour()))     print(weekBefore.formatted(.interval.day().month().minute().hour(.defaultDigitsNoAMPM)))     print(weekBefore.formatted(.interval.day().month().minute().hour(.conversationalDefaultDigits(amPM: .wide))))     print(weekBefore.formatted(.interval.day().month().minute().hour(.conversationalDefaultDigits(amPM: .narrow)))) } // 2/5/2021, 9 – 2/12/2021, 9 // 5, 7:09 AM – 12, 7:09 AM // Feb 5, 07:09 – Feb 12, 07:09 // Feb 5, 7:09 AM – Feb 12, 7:09 AM // Feb 5, 7:09 a – Feb 12, 7:09 a

## See Also

### Modifying Date Interval Format Styles

- [day()](foundation/date/intervalformatstyle/day().md)
- [minute()](foundation/date/intervalformatstyle/minute().md)
- [month(_:)](foundation/date/intervalformatstyle/month(_:).md)
- [second()](foundation/date/intervalformatstyle/second().md)
- [weekday(_:)](foundation/date/intervalformatstyle/weekday(_:).md)
- [year()](foundation/date/intervalformatstyle/year().md)
