//格式化日期 function formatDate(d){ var date1=new Date(d); var CurrentDate = ""; //初始化时间 var Year= date1.getFullYear();//ie火狐下都可以 var Month= date1.getMonth()+1; var Day = date1.getDate(); var Hours = date1.getHours(); var Minutes = date1.getMinutes(); var Seconds = date1.getSeconds(); CurrentDate += Year + "年"; Month >= 10 ? (CurrentDate += Month + "月"):(CurrentDate += "0" + Month + "月"); Day >= 10 ? (CurrentDate += Day +"日 "):(CurrentDate += "0" + Day+"日 "); Hours>=10 ? (CurrentDate += Hours +":"):(CurrentDate += "0"+Hours +":"); Minutes>=10 ? (CurrentDate += Minutes +":"):(CurrentDate += "0"+Minutes +":"); Seconds>=10 ? (CurrentDate += Seconds):(CurrentDate += "0"+Seconds); return CurrentDate; }