【javascript】获取 格式化时间

  function getDate() {
                var myDate = new Date();
                var month = myDate.getMonth() + 1;
                var day = myDate.getDate();
                month = (month.toString().length == 1) ? ("0" + month) : month;
                day = (day.toString().length == 1) ? ("0" + day) : day;
 
                var result = myDate.getFullYear() + month + day; //当前日期
 
                return result;
            }

//20190314

 

posted @ 2019-03-14 15:52  expworld  阅读(162)  评论(0编辑  收藏  举报