[学习笔记]JS获取指定日期前一天

var mydate=new Date(Date.parse(stockdate.replace(/-/g,"/")));
var yesterday_milliseconds=mydate.getTime()-1000*60*60*24; 
var yesterday=new Date(); 
yesterday.setTime(yesterday_milliseconds); 

var strYear=yesterday.getFullYear(); 
var strDay=yesterday.getDate(); 
var strMonth=yesterday.getMonth()+1; 
if(strMonth<10) 

strMonth="0"+strMonth; 

var strYesterday=strYear+"-"+strMonth+"-"+strDay;

你可能感兴趣的:([学习笔记]JS获取指定日期前一天)