js获取当前时间格式化字符串


var today = new Date();

var month = today.getMonth() + 1;

month = month < 10 ? '0'+month : month;

var day = today.getDate() < 10 ? '0'+today.getDate() : today.getDate();

var hours = today.getHours() < 10 ? '0'+today.getHours() : today.getHours();

var mins = today.getMinutes() < 10 ? '0'+today.getMinutes() : today.getMinutes();

var secs = today.getSeconds() < 10 ? '0'+today.getSeconds() : today.getSeconds();

 

var now1 = today.getFullYear() + '/' + month + '/' + day;

var now1 = today.getFullYear() + '/' + month + '/' + day + “ ” + hours + ":" + mins + ":" + secs ;


免责声明!

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



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