JS 把时间戳转化成YY-MM-DD

//把时间戳转换YY-MM--dd
MyInformation.prototype.format = function(date){
    var format = "",oY ="",oM = "",oD="";
    var oDate = new Date(date);
    oY = oDate.getFullYear();
    oM = oDate.getMonth() + 1;
    oM = oM < 10?"0"+oM:oM;
    oD = oDate.getDate();
    oD = oD < 10?"0"+oD:oD;
    format = oY+"-"+oM+"-"+oD;
    return format;
};

转载于:https://my.oschina.net/u/2276582/blog/719508

你可能感兴趣的:(JS 把时间戳转化成YY-MM-DD)