Js日期格式化

    //自定义日期转换合适
    Date.prototype.toLocaleString = function() {
        //return this.getFullYear() + "-" + (this.getMonth() + 1) + "-" + this.getDate() + " " + this.getHours() + ":" + this.getMinutes() + ":" + this.getSeconds();
        return this.getFullYear() + "-" + (this.getMonth() + 1) + "-" + this.getDate();
    };

    var time= new Date(1512696580915);
    time= time.toLocaleString();
    alert(time);

你可能感兴趣的:(Js日期格式化)