当前位置:   article > 正文

获取当前日期后五天_获取当前日期@now(yyyy-mm-dd);后5天日期

获取当前日期@now(yyyy-mm-dd);后5天日期

一、获取当前日期的时间戳

主要代码:

// 获取当前日期以及后4天
function GetDateStr(AddDayCount) {
   var _date = new Date();
   var currentWeek = _date.getDay();
   _date.setDate(_date.getDate() + AddDayCount); //获取AddDayCount天后的日期  
   var years = _date.getFullYear();
   var months = (_date.getMonth() + 1) < 10 ? "0" + (_date.getMonth() + 1) : (_date.getMonth() + 1); //获取当前月份的日期,不足10补0  
   var days = _date.getDate() < 10 ? "0" + _date.getDate() : _date.getDate(); //获取当前几号,不足10补0  
   var dates = new Date(years, months - 1, days);
   var _week;
   if(dates.getDay() == 0) _week = "周日";
   if(dates.getDay() == 1) _week = "周一";
   if(dates.getDay() == 2) _week = "周二";
   if(dates.getDay() == 3) _week = "周三";
   if(dates.getDay() == 4) _week = "周四";
   if(dates.getDay() == 5) _week = "周五";
   if(dates.getDay() == 6) _week = "周六";
   return months + "月" + days + "日" + "[" + _week + "]";
}
// 默认时间为todays
$("#nowDates").text(GetDateStr(0));
console.log("今天:" + GetDateStr(0));
console.log("明天:" + GetDateStr(1));
console.log("后天:" + GetDateStr(2));
console.log("大后天:" + GetDateStr(3));
console.log("大大后天:" + GetDateStr(4));


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/313731?site
推荐阅读
相关标签
  

闽ICP备14008679号