Date Picker

Improve this doc

$ ionic plugin add cordova-plugin-datepicker

Repo: https://github.com/VitaliiBlagodir/cordova-plugin-datepicker

The DatePicker plugin allows the user to fetch date or time using native dialogs.

Supported platforms

Usage

import { DatePicker } from 'ionic-native';


DatePicker.show({
  date: new Date(),
  mode: 'date'
}).then(
  date => console.log('Got date: ', date),
  err => console.log('Error occurred while getting date: ', err)
);

Static Members

show(options)

Shows the date and/or time picker dialog(s)

Param Type Details
options DatePickerOptions

Options for the date picker.

Returns: Promise<Date> Returns a promise that resolves with the picked date and/or time, or rejects with an error.

DatePickerOptions

Param Type Details
mode string

The mode of the date picker Values: date | time | datetime

date Date | string | number

Selected date

minDate
(optional)
Date | string | number

Minimum date Default: empty String

maxDate
(optional)
Date | string | number

Maximum date Default?: empty String

titleText
(optional)
string

Label for the dialog title. If empty, uses android default (Set date/Set time). Default?: empty String

okText
(optional)
string

Label of BUTTON_POSITIVE (done button) on Android

cancelText
(optional)
string

Label of BUTTON_NEGATIVE (cancel button). If empty, uses android.R.string.cancel.

todayText
(optional)
string

Label of today button. If empty, doesn't show the option to select current date.

nowText
(optional)
string

Label of now button. If empty, doesn't show the option to select current time.

is24Hour
(optional)
boolean

Shows time dialog in 24 hours format.

androidTheme
(optional)
number

Choose the Android theme for the picker. You can use the DatePicker.ANDROID_THEMES property. Values: 1: THEME_TRADITIONAL | 2: THEME_HOLO_DARK | 3: THEME_HOLO_LIGHT | 4: THEME_DEVICE_DEFAULT_DARK | 5: THEME_DEVICE_DEFAULT_LIGHT

allowOldDates
(optional)
boolean

Shows or hide dates earlier then selected date.

allowFutureDates
(optional)
boolean

Shows or hide dates after selected date.

doneButtonLabel
(optional)
string

Label of done button.

doneButtonColor
(optional)
string

Hex color of done button.

cancelButtonLabel
(optional)
string

Label of cancel button.

cancelButtonColor
(optional)
string

Hex color of cancel button.

x
(optional)
number

X position of date picker. The position is absolute to the root view of the application.

y
(optional)
number

Y position of date picker. The position is absolute to the root view of the application.

minuteInterval
(optional)
number

Interval between options in the minute section of the date picker.

popoverArrowDirection
(optional)
string

Force the UIPopoverArrowDirection enum. The value any will revert to default UIPopoverArrowDirectionAny and let the app choose the proper direction itself.

locale
(optional)
string

Force locale for datePicker.

API

Native

General