js 时间格式化
var dtNow = new Date(); var year = dtNow.getFullYear(); var month = ('0' + (dtNow.getMonth() + 1)).slice(-2); var date = ('0' + dtNow.getDate()).slice(-2); var hour = ('0' + dtNow.getHours()).slice(-2); var min =('0' + dtNow.getMinutes()).slice(-2); var nowStr = year + "-" + month + "-" + date + " " + hour + ":" + min; 来源: https://www.cnblogs.com/liuqiyun/p/11576969.html