var DsrUtil = function(){
//获取当前时间
function getTime(type){
var now = new Date();
var year = now.getFullYear().toString();
var month = (now.getMonth() + 1).toString();
var day = now.getDate().toString();
var hour = now.getHours().toString();
var minute = now.getMinutes().toString();
var second = now.getSeconds().toString();
if (month.length == 1) {
month = "0" + month;
}
if (day.length == 1) {
day = "0" + day;
}
if (hour.length == 1) {
hour = "0" + hour;
}
if (minute.length == 1) {
minute = "0" + minute;
}
if (second.length == 1) {
second = "0" + second;
}
if(type == "1"){
return year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
}else if(type == "2"){
return year+"-"+month+"-"+day+" "+hour+":"+minute;
}else if(type == "3"){
return year+"-"+month+"-"+day;
}else{
return year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
}
}
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)