time picker always return invalid date
See original GitHub issuereact-native-modal-datetime-picker: “^6.0.0”, react-native: “0.55.4”
Platform: Android
handleTimePicked = (time) => {
console.log(time); // Invalid date
this.hideTimePicker();
};
<DateTimePicker
mode='time'
date={new Date(this.state.selectedTime)}
isVisible={this.state.isTimePickerVisible}
onConfirm={this.handleTimePicked}
onCancel={this.hideTimePicker}
/>
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
JavaScript invalid date from DateTime Picker - Stack Overflow
But your expected date is Day/Month/Year. For example, the date 04/12/2017 is returning April 12th instead of December 4th. You can use a...
Read more >A date from the Date Picker is an invalid date!
Datepicker returning time. Teodor November 26, 2021, 1:04pm #2. The validator expects a date in yyyy-mm-dd or yyyy/mm/dd format.
Read more >RangeError: invalid date - JavaScript - MDN Web Docs
The JavaScript exception "invalid date" occurs when a string leading to an invalid date has been provided to Date or Date.parse() .
Read more >How to prevent entering an invalid date for the ... - IBM
The Date Time Picker BPM UI control is not working as expected. When you first select a date from Date Time Pickerand then...
Read more >Invalid Date from Date picker in Mobile App - ServiceNow
Our default date format has always been set to MM-dd-yyyy. But when we select the Date/Time field and pick a date from the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
import DateTimePicker from ‘react-native-modal-datetime-picker’; import moment from ‘moment’;
constructor(props) { super(props); this.state = { selectedDate: moment(new Date()).format(‘DD-MM-YYYY’), selectedTime: moment(new Date()).format(‘HH:mm’), }; }
handleDatePicked = (date) => { const newDate = moment(new Date(date.toString().substr(0, 16))).format(‘DD-MM-YYYY’); this.setState({ selectedDate: newDate }); this.hideDatePicker(); };
<DateTimePicker date={new Date(this.state.selectedDate)} isVisible={true/false} onConfirm={this.handleDatePicked} onCancel={this.hideDatePicker} />
@VKGraphics
worked, like this
Yup, worked,