<div class="col-md-2">
<input style="border: 1px solid #ddd; width:96px; padding:7px 10px 6px 10px; font-weight: 500; margin-left: 100px;" type="text"
placeholder="start Date" id="startFilter">
<div style="margin-top: -29px;margin-left: 220px; font-weight:700; font-size: 14px">to:</div>
</input>
</div>
<div class="col-md-2">
<div class="col-mod-1">
</div>
<input type="text" style="border: 1px solid #ddd; font-weight: 500; width:96px; padding:7px 10px 6px 10px; margin-left: 69px;"
placeholder="End date" id="endFilter" onchange="Date(this)"/>
</div>
var start_selected_date = "";
$( function() {
var time = [];
var dateFormat = "mm/dd/yy",
from = $( "#startFilter" )
.datepicker({
defaultDate: "+1d",
changeMonth: true,
numberOfMonths: 1,
})
.on( "change", function() {
to.datepicker( "option", "minDate", getDate( this ) );
var startselected = $(this).val();
start_selected_date = Date.parse(startselected);
console.log(start_selected_date);
}),
to = $( "#endFilter" ).datepicker({
defaultDate: "+1d",
changeMonth: true,
numberOfMonths: 1
})
.on( "change", function() {
//from.datepicker( "option", "maxDate", getDate( this ) );
var endselected = $(this).val();
var end_selected_date = Date.parse(endselected);
console.log(end_selected_date);
var filtered_Data = [];
for (var i=0; i< all_data.length; i++){
var gi = all_data[i].time_stamp;
time = Date.parse(new Date(gi));
console.log(time);
if ( end_selected_date >= time && start_selected_date <= time ) {
//console.log(all_data[i]);
filtered_Data.push(all_data[i]);
}
else if(new Date(end_selected_date)==(all_data[i].time_stamp).slice(0,10)){
filtered_Data.push(all_data[i]);
}
console.log(endselected, new Date(all_data[i].time_stamp));
}
// console.log(filtered_Data);
getParticipantsDetails(filtered_Data);
});
function getDate( element ) {
var date;
try {
date = $.datepicker.parseDate( dateFormat, element.value );
} catch( error ) {
date = null;
}
return date;
}
});
I want to trim the data after as per the highlighted part
我有一个Json数据,我确实想根据日期过滤数据。当我选择开始日期和结束日期相等时,我将无法筛选数据。休息正常。我为日期选择器使用了Jquery插件。任何帮助都是可观的。