I am currently working on a reminders app and I added a DateTimePickerModal
from the package react-native-modal-datetime-picker
and I wanted to know how to format the data...
This is the code for the component
<DateTimePickerModal
isVisible={this.state.modalVisible}
mode="datetime"
onConfirm={onConfirm}
onCancel={onCancel}
/>
Code for the onConfirm
function
const onConfirm = (dateAndTime) => {
this.setState({ dateAndTime: dateAndTime.toString() });
hideModal();
};
The data I'm getting:
Converted into string: Mon May 03 2021 16:01:37 GMT+0530 (IST)
Without converting it to string: 2021-05-06T09:31:37.000Z
If you have any idea on how to do this please let me know...Thanks in advance!