I try to calculate the difference of two dates with a date picker.
But I have a problem, it’s the fact that the format date is not good and I when I try to change it, the response of my result become false (I see NaN). And when my dates have the good format and my result become good, my datas don’t be save with my form.
I need someone to help me, thanks a lot.
function showDays()
{
var start = $('.date_debut').datepicker('getDate');
var end = $('.date_fin').datepicker('getDate');
if (!start || !end) return;
var days = (end - start) / 1000 / 60 / 60 / 24;
days = days + 1;
$('.date_debut').val(start);
$('.date_fin').val(end);
$('.resultat').val(days);
}
$('.date_debut').datepicker({ onSelect: showDays });
$('.date_fin').datepicker({ onSelect: showDays });