//将时间戳转为时间格式 var time = new Date(parseInt(shijianchuo)); var year = time.getFullYear(); var month = time.getMonth()+1; var date = time.getDate(); var hour = time.getHours(); var minute = time.getMinutes(); var second = time.getSeconds(); //添加前导0,如1变为01 function addZero(num){ return num < 10 ? '0'+num : num; } return year + '-' + addZero(month) + '-' + addZero(date) + ' ' + addZero(hour) + ':' + addZero(minute) + ':' + addZero(second);