easyui时的时间格式yyyy-MM-dd与yyyy-MM-ddd HH:mm:ss

easyui日期的转换,日期汉化导入:<script type="text/javascript" src="../easyui/locale/easyui-lang-zh_CN.js"></script>

重写我们想要的格式:

1这种返回yyyy-MM-dd HH:mm:ss

$(function(){
$('.easyui-datetimebox').datetimebox({
formatter: function (date) {
var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0" + (date.getMonth() + 1);
var hor = date.getHours();
var min = date.getMinutes();
var sec = date.getSeconds();
return date.getFullYear() + '-' + month + '-' + day+" "+hor+":"+min+":"+sec;
}
});
});
2这种返回yyyy-MM-dd
$(function () {
$('.easyui-datebox').datebox({
formatter: function (date) {
// //格式化
return date.getFullYear() + '-' + (date.getMonth() + 1) +
'-' + date.getDate();
return date;
},
parser: function (s) {
// return new Date(2015,6,1);

}
});
//获得日历控件
$(".easyui-datebox").datebox('calendar').calendar({
firstDay: 1,//设置每周的第一天为周一
});
});
 

猜你喜欢

转载自www.cnblogs.com/wangbiaohistory/p/10586244.html