其他分享
首页 > 其他分享> > JS返回当前时间(年、月、日、时、分、秒)

JS返回当前时间(年、月、日、时、分、秒)

作者:互联网

function getDateTime() {
 var date = new Date(),
 year = date.getFullYear(),
 month = date.getMonth() + 1,
 day = date.getDate(),
 hour = date.getHours() + 1,
 minute = date.getMinutes(),
 second = date.getSeconds();
 month = checkTime(month);
 day = checkTime(day);
 hour = checkTime(hour);
 minute = checkTime(minute);
 second = checkTime(second);
 function checkTime(i) {
 if (i <10) {
 i = “0” + i;
 }
 return i;
 }
 return “” + year + “year” + month + “month” + day + “day” + hour + “hour” + minute + “minute” + second + “second”
}

 

标签:返回,checkTime,JS,second,当前,date,month,day,minute
来源: https://www.cnblogs.com/konglxblog/p/15756624.html