js phpタイムスタンプをフォーマット日に変換

645 ワード

    //js php           
    function to_date(phpstr) {
        str = parseInt(phpstr) * 1000;// php           1000
        var newDate = new Date(str);
        var year = newDate.getUTCFullYear();//   
        var month = newDate.getUTCMonth() + 1;//   
        var nowday = newDate.getUTCDate();//   
        var hours = newDate.getHours();//   
        var minutes = newDate.getMinutes();//   
        var seconds = newDate.getSeconds();//  
        return year + "-" + month + "-" + nowday + " " + hours + ":" + minutes + ":" + seconds;//   2017-2-21 12:23:43    }

    }