js将时间戳转换为日期类型

function getLocalTime(nS) {   
    var date = new Date(nS);
    Y = date.getFullYear() + '年';
    M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '月';
    D = date.getDate() + '日 ';
    h = date.getHours() + ':';
    m = date.getMinutes() + ':';
    s = date.getSeconds();

    return Y+M+D+h+m+s;
}   

你可能感兴趣的:(js将时间戳转换为日期类型)