var d = new Date( date );
d.setMonth( d.getMonth( ) - 1 );
jQuery Datepicker output formatted date minus 1 month
-
30-07-2022 - |
문제
I am trying to do the following:
When selecting a date with the jquery datepicker, get the value as the same date but from previous month. Format as mmddyy
so if you select 11-13-2013, then it will return 10132013 as the value for the input field.
I managed to get the formatting, but not the previous month.
here is the script:
$('#choose-date').change(function(){
var date = $(this).datepicker('getDate');
var formatted_date = $.datepicker.formatDate('mmddyy', date);
window.location = '/getpage.do?date=' + formatted_date;
})
The field for the datepicker is a simple text input
Any thoughts?
This is the new finished script:
jq$('#choose-date').change(function(){
var date = jq$(this).datepicker('getDate');
var d = new Date( date );
d.setMonth( d.getMonth( ) - 1 );
var formatted_date = jq$.datepicker.formatDate('mmddyy', d);
window.location = '/getpage.do?date=' + formatted_date;
})
해결책
제휴하지 않습니다 StackOverflow