Opens the standard Android date picker dialog.
try {
const {action, year, month, day} = await DatePickerAndroid.open({
// Use `new Date()` for current date.
// May 25 2020. Month 0 is January.
date: new Date(2020, 4, 25)
});
if (action !== DatePickerAndroid.dismissedAction) {
// Selected year, month (0-11), day
}
} catch ({code, message}) {
console.warn('Cannot open date picker', message);
}
open()
static open(options)
Opens the standard Android date picker dialog.
The available keys for the options object are:
date (Date object or timestamp in milliseconds) - date to show by defaultminDate (Date or timestamp in milliseconds) - minimum date that can be selectedmaxDate (Date object or timestamp in milliseconds) - maximum date that can be selectedmode (enum('calendar', 'spinner', 'default')) - To set the date-picker mode to calendar/spinner/default Returns a Promise which will be invoked an object containing action, year, month (0-11), day if the user picked a date. If the user dismissed the dialog, the Promise will still be resolved with action being DatePickerAndroid.dismissedAction and all the other keys being undefined. Always check whether the action before reading the values.
Note the native date picker dialog has some UI glitches on Android 4 and lower when using the minDate and maxDate options.
dateSetAction()
static dateSetAction()
A date has been selected.
dismissedAction()
static dismissedAction()
The dialog has been dismissed.
© 2015–2018 Facebook Inc.
Licensed under the Creative Commons Attribution 4.0 International Public License.
https://facebook.github.io/react-native/docs/datepickerandroid.html