I have 2 asp.net texboxes with calendar extender. I want to find out the number of days between both dates when one of the date control is changed. how can I achieve this using jquery or javascript?
// Determine the number of days between two dates. var days = millisBetween / (1000 * 3600 * 24);
Convert minutes to hours/minutes with the help of JQuery. // getting the hours. let hrs = Math. floor(mins / 60);
This should do the trick
var start = $('#start_date').val(); var end = $('#end_date').val(); // end - start returns difference in milliseconds var diff = new Date(end - start); // get days var days = diff/1000/60/60/24;
Example
var start = new Date("2010-04-01"), end = new Date(), diff = new Date(end - start), days = diff/1000/60/60/24; days; //=> 8.525845775462964
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With