把之前的脚本改了一下,楼主可以试试看
Date.prototype.Format = function (fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
var a1=this.options.form.getWidgetByName("p1").getValue();
var b1=new Date(a1);
b1.setDate(b1.getDate());
var c1=b1.Format("yyyy-MM-dd");
var a2=this.options.form.getWidgetByName("p2").getValue();
var b2=new Date(a2);
b2.setDate(b2.getDate());
var c2=b2.Format("yyyy-MM-dd");
this.options.form.getWidgetByName("p1").setValue(c1);
this.options.form.getWidgetByName("p2").setValue(c2);