iOS Date Picker

From Xojo Documentation

The Date Picker control is used to let the user choose a date or date-related value. The Date Picker can display date values in these formats:

  • Time
  • Date
  • Date and Time
  • Countdown Timer

By using a Date Picker, you can ensure that you get a valid date value from the user.

iOS Date Picker Library Icon

Below are common events, properties and methods. Refer to iOSDatePicker in the Language Reference for the complete list.



Called when the user selects a date (or time or countdown). Use the properties below to get the value that was selected.



Specifies the initial duration (in seconds) to display when Mode is Countdown Timer. It is also the currently displayed countdown duration, so use this to get the value the user has picked.


A Date value that specified the intial date to have centered in the Date Picker. It is also the currently displayed date, so use this to get the date value the user has picked. This is applicable when Mode is Date or DateAndTime.


A boolean that indicates if the date picker is enabled and can be used or disabled and cannot be used.


The maximum date that can be selected.


The minimum date that can be selected.


The number of minutes to show in the selector when Mode is Countdown Timer. The default is 1.


Specifies the type of Date Picker that is displayed (using the DatePickerMode enumeration): Time, Date, DateAndTime and CountDownTimer.



Allows you to set the default date, showing a scrolling animation to the specified date.


If you want to get notified every time the Date Picker value is changed, then use the ValueChanged event handler. If you would prefer to get the value at a time or your own choosing, you can refer to the properties.

For example, if you want to have a button that says "Get Selected Date", then it's Action event handler could have code like this:

Var selectedDate As Date
selectedDate = MyDatePicker.DefaultDate

That same code can also go in the ValueChanged event handler, which means it will be called every time the date changes.

By default the Date Picker shows the current date (when in Date or DateAndTime modes). You can also have a different date as the default by setting the DefaultDate property. This code in the Open event handler for the Date Picker sets the default date:

Var halloween As New Date(2015, 10, 31, TimeZone.Current)
MyDatePicker.DefaultDate = halloween

If you are using the Time mode and want to display a specific time, you would also set it using the CurrentDate property. In this case, be sure to set the time component of the date:

Var halloween As New Date(2015, 10, 31, 11, 15, 00, TimeZone.Current) // 11:15 am
MyDatePicker.DefaultDate = halloween

When using a CountDown Timer, you can set the initial countdown time by setting CountdownDuration in seconds. This sets the initial value to 15 minutes:

MyCountdownPicker.CountdownDuration = 60 * 15

Example Project

  • Examples/iOS/Controls/DatePickerExample

See Also

iOSDatePicker class; UserGuide:iOS UI topic