I'm using native datepicker of android in react native app , only when I use debug mode I get date, but when I cancel debug mode using real phone I get in alert 'invalid date' in same date I choose with the debug.
showDatePicker = async () => {
if (Platform.OS === 'ios') {
this.setState({ datePickerIosPlatform: true })
} else {
try {
const { action, year, month, day } = await DatePickerAndroid.open({
date: new Date()
});
if (action !== DatePickerAndroid.dismissedAction) {
console.log('action', action, 'year', year, ' month', month, 'day', day)
var stringDate = `${year} ${month} ${day}`;
var newDate = new Date(stringDate)
alert(newDate)
var convertDate = moment(newDate).format('DD.MM.YYYY')
console.log('convertdata',convertDate)
// this.convertDate(stringDate)
}
} catch ({ code, message }) {
console.warn('Cannot open date picker', message);
}
}
}