标签:gettime nbsp 时间 turn new time() class style enum
函数
getDateXHL(num) { var date = new Date(); var dateNumber = date.getTime(); var differ = num * 24 * 60 * 60 * 1000; var needDateNumber = new Date(dateNumber + differ); var year = needDateNumber.getFullYear(); var month = needDateNumber.getMonth() + 1; var day = needDateNumber.getDate(); var monthX = month < 10 ? "0" + month : month; var dayX = day < 10 ? "0" + day : day; var nowDate = year + "-" + monthX + "-" + dayX; return nowDate; }
调用
//获取7天之前日期 var aaa = getDateXHL(-7); //获取当前日期 var bbb = getDateXHL(0); //获取30天之后日期 var ccc = getDateXHL(30);
标签:gettime nbsp 时间 turn new time() class style enum
原文地址:https://www.cnblogs.com/xihailong/p/12756068.html