NativeScript Core

In this article
API Reference
Not finding the help you need?

Time Picker

NativeScript provides a TimePicker control that enables users to choose a time as a ready-to-use dialog. Every time part can be picked separately by its corresponding section of the control - for hour, minutes and AM/PM.

Basics

TimePicker can be easily configured by setting the required properties in the XML declaration or via a code-behind reference.

<TimePicker hour="10" minute="25"
            loaded="onPickerLoaded" 
            row="2" col="0" colSpan="2" 
            class="m-15" verticalAlignment="center">
</TimePicker>

Improve this document

Demo Source


Binding

The example below demonstrates setting up TimePicker's properties while using data binding.

<TimePicker loaded="onPickerLoaded" 
            hour="{{ tphour }}" minute="{{ tpminute }}" 
            minuteInterval="{{ tpminuteInterval }}"
            maxHour="{{ tpMaxHour }}" maxMinute="{{ tpMaxMinute }}"
            minHour="{{ tpMinHour }}" minMinute="{{ tpMinMinute }}" 
            verticalAlignment="center" row="4" col="0" colSpan="2" class="m-15">
</TimePicker>

Improve this document

Demo Source


Time Format

Using the NativeScript's ability to easily access the native Android and iOS APIs is allowing you to further modify the TimePicker behavior. In the example below a demonstration is made on how to change the time format from the default 12-hour (AM/PM) to 24-hour format.

<TimePicker loaded="onPickerLoaded"></TimePicker>

Improve this document

Demo Source


API Reference for the TimePicker Class

Native Component

Android iOS
android.widget.TimePicker UIDatePicker