---
title: "twoDigits(amPM:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/date/formatstyle/symbol/hour/twodigits(ampm:)"
---

# twoDigits(amPM:)

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

## Declaration

```swift
static func twoDigits(amPM: Date.FormatStyle.Symbol.Hour.AMPMStyle) -> Date.FormatStyle.Symbol.Hour
```

## Parameters

- `amPM`: Specifies the format of the day period representation.

## Return Value

Return Value An hour format style customized according to the specified day period format style and the given locale.

## Discussion

Discussion This style pads the hour with a leading zero if necessary. This style may include the day period symbol (a.m. or p.m.), depending on locale. For example, 07a (narrow), 07AM (abbreviated), 07A.M. (wide).

## See Also

### Modifying an Hour

- [defaultDigitsNoAMPM](foundation/date/formatstyle/symbol/hour/defaultdigitsnoampm.md)
- [twoDigitsNoAMPM](foundation/date/formatstyle/symbol/hour/twodigitsnoampm.md)
- [conversationalDefaultDigits(amPM:)](foundation/date/formatstyle/symbol/hour/conversationaldefaultdigits(ampm:).md)
- [conversationalTwoDigits(amPM:)](foundation/date/formatstyle/symbol/hour/conversationaltwodigits(ampm:).md)
- [defaultDigits(amPM:)](foundation/date/formatstyle/symbol/hour/defaultdigits(ampm:).md)
