日期补0

function  add_zero(time){
        var temp = time.split("-");
        if(temp[1].length==1)temp[1] = "0"+temp[1];
        if(temp[2].length==1)temp[2] = "0"+temp[2];
        return temp[0]+"-"+temp[1]+"-"+temp[2]
    }
var t = add_zero("2018-3-3");
原文地址:https://www.cnblogs.com/beimingbingpo/p/9283793.html