i have created an date range picker to get the checkin and checkout dates and I want to get the checkin checkout date difference and update the state. after that i want to show it in the input fields. But I have no idea to get the date diffrence! if anyone knows the answer please help!
state = {
checkin: '',
checkout: '',
texttwo:'
}
<DatePicker
onChange={(e) => this.dateSelected(e, 'checkout')}
/>
<DatePicker
onChange={(e) => this.dateSelected(e, 'checkin')}
/>
<Input
size="default"
placeholder="0"
value={this.state.texttwo}
onChange={(e) => this.calculate(e, 'two')}
/>
dateSelected = (date, dateType) => {
if (dateType === 'checkin') {
this.setState({
checkin: moment(date).format('YYYY-MM-DD')
});
}
else {
this.setState({
checkout: moment(date).format('YYYY-MM-DD')
});
}
if((this.state.checkin !=='') && (this.state.checkout !=='')){
let getCheckin = this.state.checkin;
let getCheckout = this.state.checkout;
let getDiff = ********
this.setState({
texttwo:getDiff
});
}
};
Aucun commentaire:
Enregistrer un commentaire