-
-
Save oshanz/8839750 to your computer and use it in GitHub Desktop.
jquery month year only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$('#from_date_txt').datepicker({ | |
changeMonth: true, | |
changeYear: true, | |
showButtonPanel: true, | |
dateFormat: 'MM yy', | |
maxDate: 0, | |
onClose: function(dateText, inst) { | |
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val(); | |
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val(); | |
$(this).datepicker('setDate', new Date(year, month, 1)); | |
var m = parseInt(month) + parseInt(1); | |
if (m < 9) { | |
m = '0' + m; | |
} | |
$(this).val(year + '-' + m + '-01'); | |
} | |
}); | |
$('#to_date_txt').datepicker({ | |
changeMonth: true, | |
changeYear: true, | |
showButtonPanel: true, | |
dateFormat: 'MM yy', | |
maxDate: 0, | |
onClose: function(dateText, inst) { | |
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val(); | |
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val(); | |
$(this).datepicker('setDate', new Date(year, month, 1)); | |
var m = parseInt(month) + parseInt(1); | |
if (m < 9) { | |
m = '0' + m; | |
} | |
$(this).val(year + '-' + m + '-'+new Date(year,m,0).getDate()); | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
.ui-datepicker-calendar { | |
display: none; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment