Friends, good afternoon ... next, the code below, takes two dates in a calendar, in the format of
DD/MM/YYYY
$('.two-calendars').on('pickmeup-change', function (evt) {
var range = pickmeup(this).get_date('d-m-Y');
if (range[0] != range[1]) {
var label = pickmeup(this).get_date("d/m/Y");
$('.search-tool .periodo .field-title').text(label[0] + " até " + label[1]);
$('.search-tool .periodo input[name=periodo]').val(range);
$('.search-tool .periodo').addClass("checked");
$('.search-tool .periodo .header-title').html(range);
}
In the last line of the function, I did the following:
$('.search-tool .periodo .header-title').html(range);
To change one written in html, by the value of the range variable. The idea is to display the number of days between the two selected dates. I have tried, subtracting range[0]
from range[1]
, and hiding the months and years, but only works when the months are the same. I believe my doubt is more mathematical than programming. If you can help me, thank you.
Here is the code that I tried to do the subtraction:
$('.search-tool .periodo .header-title').html(range[0] - range[1]);
No prompt de comando
it returns as illegal.