This question is locked. New answers and comments are not allowed.
I have a MVC - Razor DateTimePicker that i want to change the selected date on with javascript/jquery
It works fine when I change the date by a month or a year but it clears the datetimepicker when I try to change the date(by a number of days) and says the value of the datetimepicker is null if i try and read it after its been cleared.
Used in all examples:
This works:
This Doesn't:
Also tried:
And Also tried:
Thank you.
It works fine when I change the date by a month or a year but it clears the datetimepicker when I try to change the date(by a number of days) and says the value of the datetimepicker is null if i try and read it after its been cleared.
Used in all examples:
var currentTime = new Date();
var maxTime = datepicker.endTimeValue.value;This works:
currentTime.setMonth(maxTime.getMonth() - 6);<br>datepicker.value(currentTime);This Doesn't:
currentTime.setDate(maxTime.getDate() - 7);
datepicker.value(currentTime);Also tried:
var day = currentTime.getDate()
var month = currentTime.getMonth()
var year = currentTime.getFullYear()
var customDate = new Date();
customDate.setDate(day);
customDate.setMonth(month);
customDate.setFullYear(year);
datepicker.value(customDate); And Also tried:
$('#DateTimePickerStart-input').val(pad(day,2) + '/' + month + 1 + '/' + year + ' 00:00');Thank you.