输出格式 yyyy-MM-dd HH:mm:ss或yyyy-MM-dd
function formatDate(timestamp) {var date = new Date(timestamp);var year = date.getFullYear();var month = addZero(date.getMonth() + 1);var day = addZero(date.getDate());var hours = addZero(date.getHours());var minutes = addZero(date.getMinutes());var seconds = addZero(date.getSeconds());return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;//return year + '-' + month + '-' + day;}//加0function addZero(num) {return num < 10 ? '0' + num : num;}