ReactNative DatePicker
Install the date picker using below command
npm i react-native-modal-datetime-picker @react-native-community/datetimepicker
import DateTimePickerModal from "react-native-modal-datetime-picker";
Place the DatePickerModal in view as provided in the below code which has following properties
isVisible - visible when required to select the date
minimumDate - to restrict the user from selecting the date before the provided date i.e the user can select only dates ahead of minimum date.
onConfirm - once the date is selected from picker, fetching the selected date and modifications to it can be done in this.
onCancel - close the picker once you got the required date selected
How to format the selected date?
npm i --save moment
import moment from 'moment'
setFormattedDate(moment(sdate).format('yyyy-MM-DDT13:00:00.000Z'))
You can find the complete source code here
Stay tuned to my posts and do share your valuable thoughts if any queries or you would like to share anything on this topic in the comment section and please do like and share my post if this was helpful.
Hope this helped you!!
2 Comments
ReplyDeleteThis is really a very good article. Thanks for taking the time to discuss with us, I feel happy about learning this topic. keep sharing your information regularly for my future reference.
Great post. This is very informative and effective article. I think its very very helpful for us. Thanks for your nice post.
Inwizards LLC - React Native App Development Company
hire reactjs developers
reactjs development company
react native app development
Glad that it is helpful. Thanks for liking it :)
Delete