1、WdatePicker最大值限制
<!-- 日期最大值變量 --> <input type="hidden" id="limitDate"> <!-- 日期選擇款 --> <input id="seqrchDate" name="seqrchDate" type="text" style="width: 10%;cursor: pointer;" class="Wdate" autocomplete="off" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'limitDate\')}'})" readonly="readonly">
2、js日期轉換——日期轉字符串
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 dateStr = new Date().Format("yyyy-MM-dd HH:mm:ss"); // 調用
3、js日期轉換——字符串轉日期
var dateStr = new Date().Format("yyyy-MM-dd HH:mm:ss"); dateStr = dateStr.replace(/-/g, '/'); var newestDate = new Date(dateStr).getTime();
4、獲取昨天的日期
new Date((new Date().getTime()-24*60*60*1000)).Format("yyyy-MM-dd");