I try to get current year in calendar.. now year is 2016 so i don't want past years and future years only want current year ... and also month is June or any other month so i don't future months only want current and past months . when year 2017 then in calendar must be year 2017 ..when month is June or any other month then not able to select future months .. we only select only current month and past months according to year e,g, current month is June so Jan 2016.... June 2016
this is what i try but this always show past and future months /years/days
<script type="text/javascript">
$(function() {
var currentYear = (new Date).getFullYear();
var currentMonth = (new Date).getMonth();
var currentDay = (new Date).getDate();
$('#fromdate').shieldDatePicker({
minDate: new Date((currentYear - 1), 12, 1),
//minDate: 0,
dateFormat: 'yy-mm-dd',
maxDate: new Date(currentYear, currentMonth, currentDay),
//maxDate: new Date((currentYear + 1), 12, 1),
onSelect: function(selectedDate) {
// Start Date
var startDate = $(this).shieldDatePicker('getDate');
$('#todate').shieldDatePicker('option', 'minDate', startDate);
$('#todate').shieldDatePicker('setDate', startDate);
// End Date
var enddate = $(this).shieldDatePicker('getDate');
enddate.setDate(enddate.getDate()+ 7);
$('#todate').shieldDatePicker('option', 'maxDate', enddate);
}});
$('#todate').shieldDatePicker({
minDate: new Date((currentYear - 1), 12, 1),
minDate: 0,
dateFormat: 'yy-mm-dd',
maxDate: '+7'
});
});
</script>