I have a requirement where i have to filter my data based on datetime.I am retrieving data in server side and passing it to client side by serializing it.My date is in format( "2014-01-01 12:00:00").Controls i used are Telerik RadDatePicker and RadSlider, upon the change of slider value i want to filter my data by adding hours to date selected and comparing it with my data. Is there any easy way to do it in javascript which will handle all the scenarios like handling leap year scenario as the date will change when the hours will exceed 24.
This is what solve my problem.
function clientValueChange(sender, eventArgs) {
var hr = parseInt(sender._itemData[sender.get_value()].value);
if (dtWPSelDate == "")
return;
var arr = dtWPSelDate.split(' ')[0].split('-');
var dtt = new Date();
dtt.setYear(arr[0]);
dtt.setMonth(parseInt(arr[1]-1));
dtt.setDate(arr[2]);
if (eventArgs.get_oldValue() > eventArgs.get_newValue())
dtt.setHours(-hr,0,0);
else
dtt.setHours(hr,0,0);
dtt.setMinutes(0);
dtt.setSeconds(0);
if ((parseInt(hr) % 24) == 0) {
dtWPSelDate = dtt.format('yyyy-MM-dd 00:mm:ss');
}
else
dtWPSelDate = dtt.format('yyyy-MM-dd hh:mm:ss');
console.log(dtWPSelDate);
}
var dtWPSelDate ;
function DateSelected(sender, eventArgs) {
dtWPSelDate = eventArgs._newValue;
}