-1

I have searched and seen how to find the difference between times but how do I use the date inputed by the user when I'm doing it? Any help is appreciated. Thank you.

const activity = $('#activity').val();
const startValue = $('#start-time').val();
const endValue = $('#end-time').val();
const date = $('#date').val();
const timeStart = new Date("date" + startValue).getHours();
const timeEnd = new Date("date" + endValue).getHours();
const inBetween = timeEnd - timeStart;
Lance Le
  • 1
  • 1
  • 2
    Possible duplicate of [How do I get the number of days between two dates in JavaScript?](https://stackoverflow.com/questions/542938/how-do-i-get-the-number-of-days-between-two-dates-in-javascript) – Johannes H. Nov 26 '18 at 03:56

1 Answers1

0

You can do like this...

var startDate = new Date(startValue); // start time
var endDate = new Date(endValue); //end tme

var diff = endDate - startDate;

Here you can find more detailed answer.

dilusha_dasanayaka
  • 1,401
  • 2
  • 17
  • 30