admin管理员组文章数量:1313822
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;
})
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;
})
Share
Improve this question
edited Nov 15, 2013 at 12:58
greg
asked Nov 13, 2013 at 21:47
greggreg
1642 silver badges11 bronze badges
1 Answer
Reset to default 8var d = new Date( date );
d.setMonth( d.getMonth( ) - 1 );
本文标签: javascriptjQuery Datepicker output formatted date minus 1 monthStack Overflow
版权声明:本文标题:javascript - jQuery Datepicker output formatted date minus 1 month - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741934409a2405767.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论