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”
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM