Mobile DateTime Picker

From Xojo Documentation

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

  • Time
  • Date
  • Date and Time

By using a DateTime 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 MobileDateTimePicker in the Language Reference for the complete list.



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



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


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


The maximum date and/or time that can be selected.


The minimum date and/or time that can be selected.


Specifies the type of DateTime Picker that is displayed (using the DisplayModes enumeration): TimeOnly, DateOnly, and DateAndTime.


If you want to get notified every time the DateTime Picker value is changed, then use the DateChanged 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 Pressed event handler could have code like this:

Var selectedDate As DateTime
selectedDate = MyDateTimePicker.SelectedDate

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

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

Var halloween As New DateTime(2021, 10, 31)
MyDateTimePicker.SelectedDate = halloween

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

Var halloween As New DateTime(2021, 10, 31, 11, 15, 00) // 11:15 am
MyDateTimePicker.SelectedDate = halloween

Example Project

  • Examples/iOS/Controls/DatePickerExample

See Also

MobileDateTimePicker class; UserGuide:iOS User Interface Controls topic