时间戳转时间 yyyy-mm-dd hh:mm:ss

function getyyyyMMdd(data){
    var d = new Date(data*1000);
    var curr_date = d.getDate();
    var curr_month = d.getMonth() + 1;
    var curr_year = d.getFullYear();
    var curr_hour = d.getHours();;
    var curr_minute = d.getMinutes();
    var curr_second = d.getSeconds();
    String(curr_month).length < 2 ? (curr_month = "0" + curr_month): curr_month;
    String(curr_date).length < 2 ? (curr_date = "0" + curr_date): curr_date;
    String(curr_hour).length < 2 ? (curr_hour = "0" + curr_hour): curr_hour;
    String(curr_minute).length < 2 ? (curr_minute = "0" + curr_minute): curr_minute;
    String(curr_second).length < 2 ? (curr_second = "0" + curr_second): curr_second;
    yyyyMMdd = curr_year + "-" + curr_month +"-"+ curr_date+"  "+curr_hour+":"+curr_minute+":"+curr_second;
   return yyyyMMdd;
}

你可能感兴趣的:(时间戳转时间 yyyy-mm-dd hh:mm:ss)