var today = new Date();var year = today.getFullYear();var month = (today.getMonth() + 1) < 10 ? '0' + (today.getMonth() + 1) : (today.getMonth() + 1);var day = (today.getDate()) < 10 ? '0' + (today.getDate()) : (today.getDate());var hours = (today.getHours()) < 10 ? '0' + (today.getHours()) : (today.getHours());var minutes = (today.getMinutes()) < 10 ? '0' + (today.getMinutes()) : (today.getMinutes());var seconds = (today.getSeconds()) < 10 ? '0' + (today.getSeconds()) : (today.getSeconds());date1 = year + "-" + month + "-" + today.getDate() + " " + hours + ':' + minutes + ':' + seconds;alert(date1); 最近需要使用js写个当前的时间: