1 //获取当前时间,格式YYYY-MM-DD
2 function getNowFormatDate() { 3 var date = new Date(); 4 var seperator1 = "-"; 5 var year = date.getFullYear(); 6 var month = date.getMonth() + 1; 7 var strDate = date.getDate(); 8 if (month >= 1 && month <= 9) { 9 month = "0" + month; 10 } 11 if (strDate >= 0 && strDate <= 9) { 12 strDate = "0" + strDate; 13 } 14 var currentdate = year + seperator1 + month + seperator1 + strDate; 15 return currentdate; 16 }