js獲取當前時間格式化字符串

var today = new Date();get

var month = today.getMonth() + 1;co

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

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 ;

相關文章
相關標籤/搜索