我正在将javascript日期转换为oracle日期格式,并继续打印旧日期。请考虑以下代码。我希望13-DEC-2016
能够在alert ("Printing Full Date: "+fullStartOracleDate);
对话框中打印,但由于某种原因,它会继续打印2-DEC-2016
。它在JSFiddle here.
var assignedOnDate = "12/13/2016";
var myJSDate = new Date(assignedOnDate);
alert ("Printing Date: "+assignedOnDate);
var monthNames = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN",
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ];
var month = myJSDate.getMonth();
var year = myJSDate.getFullYear();
var day = myJSDate.getDay();
var fullStartOracleDate = day+"-"+monthNames[month]+"-"+year;
alert ("Printing Full Date: "+fullStartOracleDate);
答案 0 :(得分:1)
var assignedOnDate = "12/13/2016";
var myJSDate = new Date(assignedOnDate);
alert ("Printing Date: "+assignedOnDate);
var monthNames = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN",
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ];
var month = myJSDate.getMonth();
var year = myJSDate.getFullYear();
var day = myJSDate.getDate();
var fullStartOracleDate = day+"-"+monthNames[month]+"-"+year;
alert ("Printing Full Date: "+fullStartOracleDate);