JS 显示周 几和 月 日

function getMyDay(date){
                var week;
                var month = date.getMonth() + 1;
                   var day = date.getDate();
                if(date.getDay()==0) week="周日"
                if(date.getDay()==1) week="周一"
                if(date.getDay()==2) week="周二"
                if(date.getDay()==3) week="周三"
                if(date.getDay()==4) week="周四"
                if(date.getDay()==5) week="周五"
                if(date.getDay()==6) week="周六"
                return week + ' ' + [month, day].map(formatNumber).join('-');
            }
            function formatNumber(n) {
                n = n.toString()
                return n[1] ? n : '0' + n
            }

 

posted @ 2017-03-08 16:47  春风得意之时  阅读(595)  评论(0编辑  收藏  举报