<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIDatePicker",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIDatePicker"
  },
  "title" : "UIDatePicker"
}
-->

# UIDatePicker

A control for inputting date and time values.

```
@MainActor class UIDatePicker
```

## Overview

You can use a date picker to allow a user to enter either a point in time (calendar date, time value, or both) or a time interval (for example, for a timer). The date picker reports interactions to its associated target object.

To add a date picker to your interface:

- Set the date picker mode at creation time.
- Supply additional configuration options such as minimum and maximum dates if required.
- Connect an action method to the date picker.
- Set up Auto Layout rules to govern the position of the date picker in your interface.

You use a date picker only for handling the selection of times and dates. If you want to handle the selection of arbitrary items from a list, use a [`UIPickerView`](/documentation/UIKit/UIPickerView) object.

### Configure a date picker

The [`datePickerMode`](/documentation/UIKit/UIDatePicker/datePickerMode) property determines the configuration of a date picker. You can set the [`datePickerMode`](/documentation/UIKit/UIDatePicker/datePickerMode) value programmatically or in Interface Builder. For modes that include date or time values, you can also configure the locale, calendar, and time zone information. The date picker uses that information when formatting date and time values for the current user, and defaults to the device’s locale, calendar, and time zone. The [`date`](/documentation/UIKit/UIDatePicker/date) property represents the currently selected date in the form of an <doc://com.apple.documentation/documentation/Foundation/NSDate> object, which is calendar and time zone agnostic.

To limit the range of dates that the user can select, assign values to the [`minimumDate`](/documentation/UIKit/UIDatePicker/minimumDate) and [`maximumDate`](/documentation/UIKit/UIDatePicker/maximumDate) properties. You can also use the [`minuteInterval`](/documentation/UIKit/UIDatePicker/minuteInterval) property to allow only specific time increments.

Setting the [`datePickerMode`](/documentation/UIKit/UIDatePicker/datePickerMode) property to [`UIDatePicker.Mode.countDownTimer`](/documentation/UIKit/UIDatePicker/Mode/countDownTimer) allows the user to choose a duration in hours and minutes. When in this mode, the [`countDownDuration`](/documentation/UIKit/UIDatePicker/countDownDuration) property represents the displayed duration, measured in seconds as an <doc://com.apple.documentation/documentation/Foundation/TimeInterval>. Note that even though you set this property in seconds, the date picker can only show values in minutes.

The figure below shows a date picker configured with the [`datePickerMode`](/documentation/UIKit/UIDatePicker/datePickerMode) property set to [`UIDatePicker.Mode.countDownTimer`](/documentation/UIKit/UIDatePicker/Mode/countDownTimer) and the [`minuteInterval`](/documentation/UIKit/UIDatePicker/minuteInterval) property set to `5`. The value of [`countDownDuration`](/documentation/UIKit/UIDatePicker/countDownDuration) is currently `4500`.

![A screenshot of a wheels-style date pickering showing the selected value of 1 hour and 15 minutes.](images/com.apple.uikit/media-2279158@2x.png)

> Note:
> You can use a ``doc://com.apple.uikit/documentation/UIKit/UIDatePicker`` object for the selection of a time interval, but you must use an <doc://com.apple.documentation/documentation/Foundation/Timer> object to implement the actual timer behavior. For more information, see <doc://com.apple.documentation/documentation/Foundation/Timer>.

### Respond to user interaction

Date pickers use the target-action design pattern to notify your app when the user changes the selected date. To be notified when the date picker’s value changes, register your action method with the [`valueChanged`](/documentation/UIKit/UIControl/Event/valueChanged) event. At runtime the date picker calls your methods in response to the user selecting a date or time.

You connect a date picker to your action method using the [`addTarget(_:action:for:)`](/documentation/UIKit/UIControl/addTarget(_:action:for:)) method or by creating a connection in Interface Builder. The signature of an action method takes one of three forms, as shown in the following code. Choose the form that provides the information that you need to respond to the value change in the date picker.

```objc
- (IBAction)doSomething;
- (IBAction)doSomething:(id)sender;
- (IBAction)doSomething:(id)sender forEvent:(UIEvent*)event;
```

### Debug date pickers

When debugging issues with date pickers, watch for these common pitfalls:

- **The minimum date must be earlier than the maximum date.** Check the bounds of your [`minimumDate`](/documentation/UIKit/UIDatePicker/minimumDate) and [`maximumDate`](/documentation/UIKit/UIDatePicker/maximumDate) properties. If the maximum date is less than the minimum date, both properties are ignored, and the date picker allows the selection of any date value. The minimum and maximum dates are ignored in the countdown-timer mode ([`UIDatePicker.Mode.countDownTimer`](/documentation/UIKit/UIDatePicker/Mode/countDownTimer)).
- **The minute interval must be a divisor of 60.** Check that the [`minuteInterval`](/documentation/UIKit/UIDatePicker/minuteInterval) value can be evenly divided into 60; otherwise, the default value is used (`1`).

### Configure date picker attributes in Interface Builder

The following table lists the core attributes that you configure for date pickers in Attributes Inspector within Interface Builder.

|Attribute|Description                                                                                                                                                                                                                                                                                                                                    |
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|Style    |The date picker style. Determines the appearance of the date picker. Access this value at runtime with the ``doc://com.apple.uikit/documentation/UIKit/UIDatePicker/datePickerStyle`` property.                                                                                                                                                |
|Mode     |The date picker mode. Determines whether the date picker should display a time, a date, a time and date, or a countdown interval. Access this value at runtime with the ``doc://com.apple.uikit/documentation/UIKit/UIDatePicker/datePickerMode`` property.                                                                                    |
|Locale   |The locale associated with the date picker. This property allows you to override the system default with a specific locale. You can access this attribute programmatically with the ``doc://com.apple.uikit/documentation/UIKit/UIDatePicker/locale`` property.                                                                                |
|Interval |The granularity of the minutes spinner, if it is shown in the current mode. The default value is 1, and the maximum value is 30. The value you choose must be a divisor of 60 (1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30). Access this value at runtime with the ``doc://com.apple.uikit/documentation/UIKit/UIDatePicker/minuteInterval`` property.|

The following table lists the attributes that control the display of date and time in a date picker.

|Attribute  |Description                                                                                                                                                                                                                                                                                                                                                               |
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|Date       |The initial date that the date picker displays. Defaults to the current date, but you can set a custom value. This attribute is equivalent to setting the ``doc://com.apple.uikit/documentation/UIKit/UIDatePicker/date`` property programmatically.                                                                                                                      |
|Constraints|The range of selectable dates displayed by the date picker. To use a dynamic range, configure the ``doc://com.apple.uikit/documentation/UIKit/UIDatePicker/minimumDate`` and ``doc://com.apple.uikit/documentation/UIKit/UIDatePicker/maximumDate`` properties programmatically. The date picker ignores these options when the Mode attribute is set to Count Down Timer.|
|Timer      |The initial value of the date picker when used in countdown timer mode. The value is measured in seconds, but the display is in minutes.                                                                                                                                                                                                                                  |

For information about the date picker’s inherited Interface Builder attributes, see [`UIControl`](/documentation/UIKit/UIControl) and [`UIView`](/documentation/UIKit/UIView).

### Change the appearance

You can change the appearance of [`UIDatePicker`](/documentation/UIKit/UIDatePicker) by setting [`preferredDatePickerStyle`](/documentation/UIKit/UIDatePicker/preferredDatePickerStyle). For a list of appearance styles, see [`UIDatePickerStyle`](/documentation/UIKit/UIDatePickerStyle).

You should integrate date pickers in your layout using Auto Layout. Although date pickers can be resized, they should be used at their intrinsic content size.

### Specify a locale

Date pickers handle their own internationalization; the only thing you need to do is specify the appropriate locale. You can choose a specific locale for your date picker to appear in by setting the Locale ([`locale`](/documentation/UIKit/UIDatePicker/locale)) field in Attributes Inspector. Setting the locale changes the language that the date picker uses for display, but also the format of the date and time (for example, certain locales present days before month names, or prefer a 24-hour clock over a 12-hour clock). The width of the date picker automatically accommodates for the length of the localization. To use the system language, leave this property set to default.

For more information, see [Internationalization and Localization Guide](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/Introduction/Introduction.html#//apple_ref/doc/uid/10000171i).

### Support accessibility and VoiceOver

Date pickers are accessible by default. Each time component in the date picker is its own accessibility element and has the Adjustable ([`adjustable`](/documentation/UIKit/UIAccessibilityTraits/adjustable)) trait.

The device reads the accessibility value, traits, and hint out loud for each date picker when the user enables VoiceOver. VoiceOver speaks this information when a user taps on a picker wheel. For example, when a user taps the hours column on the Add Alarm page (Clock > Alarm > Add), VoiceOver speaks the following:

```objc
"2 o'clock. Picker item. Adjustable. Swipe up or down with one finger to adjust the value."
```

For further information about making iOS controls accessible, see the [Accessibility Programming Guide for iOS](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/iPhoneAccessibility/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008785).

## Topics

### Managing the date and calendar

[`calendar`](/documentation/UIKit/UIDatePicker/calendar)

The calendar to use for the date picker.

[`date`](/documentation/UIKit/UIDatePicker/date)

The date displayed by the date picker.

[`locale`](/documentation/UIKit/UIDatePicker/locale)

The locale used by the date picker.

[`setDate(_:animated:)`](/documentation/UIKit/UIDatePicker/setDate(_:animated:))

Sets the date to display in the date picker, with an option to animate the setting.

[`timeZone`](/documentation/UIKit/UIDatePicker/timeZone)

The time zone reflected in the date displayed by the date picker.

### Configuring the date picker mode

[`datePickerMode`](/documentation/UIKit/UIDatePicker/datePickerMode)

The mode of the date picker.

[`UIDatePicker.Mode`](/documentation/UIKit/UIDatePicker/Mode)

The mode displayed by the date picker.

### Configuring the date picker style

[`datePickerStyle`](/documentation/UIKit/UIDatePicker/datePickerStyle)

The current style of the date picker.

[`preferredDatePickerStyle`](/documentation/UIKit/UIDatePicker/preferredDatePickerStyle)

The preferred style of the date picker.

[`UIDatePickerStyle`](/documentation/UIKit/UIDatePickerStyle)

Styles that determine the appearance of a date picker.

### Configuring temporal attributes

[`maximumDate`](/documentation/UIKit/UIDatePicker/maximumDate)

The maximum date that a date picker can show.

[`minimumDate`](/documentation/UIKit/UIDatePicker/minimumDate)

The minimum date that a date picker can show.

[`minuteInterval`](/documentation/UIKit/UIDatePicker/minuteInterval)

The interval at which the date picker should display minutes.

[`countDownDuration`](/documentation/UIKit/UIDatePicker/countDownDuration)

The value displayed by the date picker when the mode property is set to show a countdown time.

[`roundsToMinuteInterval`](/documentation/UIKit/UIDatePicker/roundsToMinuteInterval)

A Boolean value that determines whether the date rounds to a specific minute interval.



---

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)