在项目中经常用到记录一下。(重要)
function ChangeDateToString(DateIn) {
var Year = 0;
var Month = 0;
var Day = 0;
var CurrentDate = "";
Year = DateIn.getFullYear();
Month = DateIn.getMonth() + 1;
Day = DateIn.getDate();
CurrentDate = Year + "-";
if (Month >= 10) {
CurrentDate = CurrentDate + Month + "-";
} else {
CurrentDate = CurrentDate + "0" + Month + "-";
}
if (Day >= 10) {
CurrentDate = CurrentDate + Day;
} else {
CurrentDate = CurrentDate + "0" + Day;
}
return CurrentDate;
}