我正在使用一个js函数,我只能解析两种不同的日期格式。如果用户想要一些其他日期格式,它就不会拍摄。
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()+' '+jsDate.getFullYear();
} else {
date1 = shortWeekday[jsDate.getDay()]+' '+jsDate.getMonth()+' '+jsDate.getDate()+' '+jsDate.getFullYear();
}
document.getElementById(id).value = date1;
}