一句话搞定日期减一年

new Date(new Date()-365*24*60*60*1000).getFullYear()+'-'+(new Date(new Date()-365*24*60*60*1000).getMonth()+1<10?'0'+(new Date(new Date()-365*24*60*60*1000).getMonth()+1):(new Date(new Date()-365*24*60*60*1000).getMonth()+1))+'-'+(new Date(new Date()-365*24*60*60*1000).getDate()<10?'0'+new Date(new Date()-365*24*60*60*1000).getDate():new Date(new Date()-365*24*60*60*1000).getDate())

详细逻辑如下:

localdate = new Date(); //Sat Jul 20 2013 10:43:36 GMT+0800 (中国标准时间)
 lastyear= new Date(localdate -365*24*60*60*1000); //Fri Jul 20 2012 10:43:36 GMT+0800 (中国标准时间) 减一个月只需要把365改为30即可 
 year=lastyear.getFullYear(); //2012
 month = lastyear.getMonth()+1; //7
 month = month<10?'0'+month:month; //"07"
 day = lastyear.getDate();//20
 day = day<10?'0'+day:day;//"20"
 LastYear = year+'-'+month+'-'+day; //"2012-07-20"