获取当前日期后五天

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

主要代码:

// 获取当前日期以及后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));


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值