js 日期处理

function fmtDate(obj){
      var date = new Date(parseInt(obj.time,10));
            var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
            var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            var newTime = date.getFullYear() + "-" + month + "-" + currentDate;
      return newTime;
}

 

posted @ 2019-05-06 22:32  ClimberZheng  阅读(144)  评论(0编辑  收藏  举报