You can use Moment.js to parse dates, it will accept most formats. You can then use the .diff function to get the difference in whichever time period you wish.
We'll first split the string using whichever RegEx pattern we consider most appropriate.
The Moment.js parser ignores non-alphanumeric characters, so both of the following will return the same thing:
moment("12-25-1995", "MM-DD-YYYY");
moment("12/25/1995", "MM-DD-YYYY");
This gives a degree of flexibility with parsing.
dateString = '2019-08-01 to 2019-08-03';
dates = dateString.split(/\s\w+\s/);
date1 = new moment(dates[0], 'YYYY-MM-DD');
date2 = new moment(dates[1], 'YYYY-MM-DD');
differenceDays = date2.diff(date1, 'days');
console.log('Difference in days: ', differenceDays);
// This will also work with other separators
dateString = '2019/08/01 bis 2019.08.03';
dates = dateString.split(/\s\w+\s/);
date1 = new moment(dates[0], 'YYYY-MM-DD');
date2 = new moment(dates[1], 'YYYY-MM-DD');
differenceDays = date2.diff(date1, 'days');
console.log('Difference in days (different separators): ', differenceDays);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>