Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- import { DatePickerAndroid } from 'react-native';
- const random = {
- async datePicker(){
- try {
- var today = new Date();
- var afterTomorrow = today.setDate(today.getDate()+2);
- const {action, year, month, day} = await DatePickerAndroid.open({
- date: new Date(),
- minDate: new Date(),
- maxDate: afterTomorrow,
- mode: 'calendar'
- });
- if (action !== DatePickerAndroid.dismissedAction) {
- // Selected year, month (0-11), day
- this.setState({
- this.state.time: day+"/"+month+"/"+year
- });
- }
- } catch ({code, message}) {
- alert('Cannot open date picker: '+message);
- }
- }
- }
- export default random;
Add Comment
Please, Sign In to add comment