2
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 tried, subtract the range[0]
for range[1]
, and hide the months and years, but it only works when the months are equal. I believe my doubt is more mathematical than about programming. If you can help me, I’d appreciate it.
Here’s the code I tried to subtract:
$('.search-tool .periodo .header-title').html(range[0] - range[1]);
In the prompt de comando
he returns as illegal.
Here’s your answer: https://answall.com/a/86768/11482
– caiocafardo