js 时间

var up = new Date();
 up.setMonth(up.getMonth()-1);
 var up_year=up.getFullYear();
 var up_month=up.getMonth()+1;
 var up_day=up.getDate();

 var now = new Date();
 var now_year=now.getFullYear();
 var now_month=now.getMonth()+1;
 var now_day=now.getDate();
 
 if(up_month<10){
  up_month="0"+up_month;
 }
 if(up_day<10){
  up_day="0"+up_day;
 }
 
 if(now_month<10){
  now_month="0"+now_month;
 }
 if(now_day<10){
  now_day="0"+now_day;
 }

原文地址:https://www.cnblogs.com/yangy608/p/2318172.html