var y = date.getFullYear(); var m = fullnum(date.getMonth()+1); var d = fullnum(date.getDate()); return y+'-'+m+'-'+d; }; function fullnum(obj){//对于月小于10格式的转换,因为Timestamp转换必须是2013-01-04这种格式 if(Number(obj) < 10){ return '0' + obj; }else{ return obj; } }