I have two kinds of formats
May 16, 12:00 PM-May 17, 12:00 AM
May 16, 12:00 PM-1:00 PM.
I want to know the number of hours between two times. I used the moment to calculate for Option 2 with the following code
Eg: May 16, 12:00 PM-1:30 PM will return 1.5 hours
let dateTime = availablity.split(',');
let dateTimes = availablity.split('-');
let times = dateTime[1].split('-');
var start = moment(times[0], 'hh:mm a');
var end = moment(times[1], 'hh:mm a');
var startTime = moment(start);
var endTime = moment(end);
var x = moment.duration(endTime.diff(startTime));
var tempTime = moment.duration(x);
var hours = tempTime.as('hours');
How can I use the similar code to achieve number of hours for 1 format as time has for next day