开发者

To get the date format by customizing it

开发者 https://www.devze.com 2023-01-25 14:06 出处:网络
I am using a js function where i can parse only 2 different date formats.If a user wants some other Date format its not taking.

I am using a js function where i can parse only 2 different date formats.If a user wants some other Date format its not taking.

 function getFormattedDate(id) {

            var start =  document.getElementById(id).value;
            var jsDate = new Date(start);
            var shortWeekday = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
            var fullWeekday = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
            var date1="";
           <%  String dateFormat1 = (String) session.getAttribute("calendarDateFormat");%>
           var df = '<%= dateFormat1%>';
           if(df.indexOf("EEEE") != -1) {
               date1 = fullWeekday[jsDate.getDay()]+' '+jsDate.getMonth()+' '+jsDate.getDate()+' '+js开发者_运维知识库Date.getFullYear();
           } else {
               date1 = shortWeekday[jsDate.getDay()]+' '+jsDate.getMonth()+' '+jsDate.getDate()+' '+jsDate.getFullYear();
           }
           document.getElementById(id).value = date1;
       }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号