easyui_date_minute.js
/**
* 格式化数字
* @param value
* @returns
*/
function formatNumber(value){
return (value < 10 ? '0' : '') + value;
}
/**
*
* @param date
* @returns {String}
*/
function minuteTimeFormatter(date){
// debugger;
var y = date.getFullYear();
var month = date.getMonth()+1;
var d = date.getDate();
var h = date.getHours();
var minutes = date.getMinutes();
return y+'-'+month+'-'+d+' '+ formatNumber(h)+':'+formatNumber(minutes);
//var s = date.getSeconds();
//return y+'-'+m+'-'+d+' '+ formatNumber(h)+':'+formatNumber(M)+':'+formatNumber(s);
}
function minuteTimeParser(s){//2017-11-4 19:16
// debugger;
if (!s) return new Date();
var strArray = s.split(" ");//[2017-11-4,19:16]
var dateArray = strArray[0].split("-");//[2017,11,4]
var y = dateArray[0];
var month = dateArray[1];
var d = dateArray[2];
var timeArray = strArray[1].split(":");//[19,16]
var h = timeArray[0];
var minutes = timeArray[1];
var sec = "0";
if (!isNaN(y) && !isNaN(month) && !isNaN(d) && !isNaN(h) && !isNaN(minutes) ){
return new Date(y, month-1, d, h, minutes, sec);
} else {
return new Date();
}
}
html
<input class="easyui-datetimebox" style="width:173px;" type="text" id="startBidDate" name="startBidDate" data-options="required:true,formatter:minuteTimeFormatter,parser:minuteTimeParser,editable:false" placeholder="请选择日期"></input>