I'm using "react-date-range" to create a calendar which allows the user to select his check-in and check-out dates. But how do I get the number of days which the user wants to stay for example if I'm selecting 1st as my (start date) and 10th as my (end-date) then the number of days I would be staying in the hotel would be 9. can somebody please help me implement this
My CalendarFunc Component
import React from 'react'
import 'react-date-range/dist/styles.css'; // main style file
import 'react-date-range/dist/theme/default.css'; // theme css file
import { DateRangePicker } from 'react-date-range';
import { useState } from 'react';
const CalendarFunc = (props) => {
const [startDate, setStartDate] = useState(new Date());
const [endDate, setEndDate] = useState(new Date());
const handleSelect=(ranges) =>{
console.log(ranges.selection.startDate);
console.log(ranges.selection.endDate)
}
const selectionRange = {
startDate: startDate,
endDate: endDate,
key: "selection"
}
return (<div className='calendarHolder'>
{props.buttonopenState && <DateRangePicker ranges={[selectionRange]} minDate={new Date()} rangeColors={["#FD5B61"]} onChange={handleSelect} /> }
</div>)
}
export default CalendarFunc
Can somebody please help me implement the number of days the user stays in the hotel by subtracting his check-in and check-out date