数码资讯
如何使用Javascript从N天前获取日期
复制代码代码如下所示: 功能测试(日){ var =新日期(); 无功beformilliseconds = today.gettime()- 1000 * 3600 * 24 *天; 无功beforday =新的日期(); beforday.settime(beformilliseconds);
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
复制代码代码如下所示:
功能测试(日){
var =新日期();
无功beformilliseconds = today.gettime()- 1000 * 3600 * 24 *天;
无功beforday =新的日期();
beforday.settime(beformilliseconds);
无功stryear = beforday.getfullyear();
无功strday = beforday.getdate();
无功strmonth = beforday.getmonth()+ 1;
如果(strmonth<10){
strmonth =0+ strmonth;
}
无功stryesterday = stryear +-+ strmonth +-+ strday;
警报(stryesterday);
}
功能测试(日){
var =新日期();
无功beformilliseconds = today.gettime()- 1000 * 3600 * 24 *天;
无功beforday =新的日期();
beforday.settime(beformilliseconds);
无功stryear = beforday.getfullyear();
无功strday = beforday.getdate();
无功strmonth = beforday.getmonth()+ 1;
如果(strmonth<10){
strmonth =0+ strmonth;
}
无功stryesterday = stryear +-+ strmonth +-+ strday;
警报(stryesterday);
}
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。