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;
}
精彩评论