datetimepicker选择获取当前的日期

//	1、可以这么写
$(".customerDate").datetimepicker({
    autoclose: true,
    todayHighlight: true,
    language: "zh-CN",
    minView: "month",
    format: "yyyy-mm-dd"
}).on('changeDate', function (ev) {
	var monthShow = (ev.date.getMonth() + 1).toString();//月
	var monthsshow = (monthShow < 10 ? "0" + monthShow : monthShow);
    var days=ev.date.getDate().toString();//日
    var dayshow = (days < 10 ? "0" + days : days);
   
    var hourshow = (ev.date.getHours().toString() < 10 ? "0" + ev.date.getHours().toString() : ev.date.getHours().toString());//小时
    var getMinute= (ev.date.getMinutes()  < 10 ? "0" + ev.date.getMinutes(): ev.date.getMinutes());//分钟
    var getSecond = (ev.date.getSeconds().toString() < 10 ? "0" + ev.date.getSeconds().toString() : ev.date.getSeconds().toString()); //秒
    plandatesDate = ev.date.getFullYear().toString() + "-" + monthsshow + "-" + dayshow + " " + hourshow + ":" + getMinute + ":" + getSecond;
    //console.log(plandatesDate);//年-月-日 时:分:秒
})

//2、也可以这么 写
$('#customerDate').datetimepicker().on('changeDate', function (ev) {
    //内容省略
})

你可能感兴趣的:(jquery,js,jquery,javascript)