当前位置:网站首页>JS to get the date in the next seven days of the current date
JS to get the date in the next seven days of the current date
2022-06-13 08:33:00 【BUG_ Jia】
getday2() {
let days = [];
var day = new Date();
for(let i=0; i<=144;i+=24){ //144 Is the number of hours in the first six days
let dateItem=new Date(day.getTime() - i * 60 * 60 * 1000); // Use the timestamp of the day minus the previous time in milliseconds ( Hours * branch * second * millisecond )
let y = dateItem.getFullYear(); // Get year
let m = dateItem.getMonth() + 1; // Get month js Month from 0 Start , need +1
let d= dateItem.getDate() + 7; // Get date
m = this.addDate0(m); // Make up zero for odd months
d = this.addDate0(d); // Fill in zeros for odd dates
let valueItem= y + '-' + m + '-' + d; // Combine
days.push(valueItem); // Add to array
}
console.log(' Date of last seven days :',days);
// Arrange the acquired dates in order
let arr=days.reverse();
let obj={};
for (let key in arr) {
obj[key] = arr[key];
};
let newObj = Object.keys(obj).map(val => ({
day: obj[val]
}));
console.log(newObj)
},
// Add to the date 0
addDate0(time) {
if (time.toString().length == 1) {
time = '0' + time.toString();
}
return time;
},边栏推荐
- Disk management and disk partition operation
- Daffodil upgrade (self idempotent)
- 【Pycharm踩坑记录】配置远程运行后提示,[Errno 2] No such file or directory
- Container concept and cloud native
- Shell脚本常用开发规范
- array_ Pop error: only variables should be passed by reference
- Dest0g3 520迎新賽
- Sizeof, strlen find character length
- Is there any good management software to solve the problems faced by tea wholesalers
- Reverse order and comparison of strings
猜你喜欢

JS - for cycle case: Horse grain

Svg text stroke effect

HCIP_ MGRE comprehensive experiment

d3.js&nvd3. JS - how to set the y-axis range - d3 js & nvd3. js — How to set y-axis range

Guidance process and service control

Process and scheduled task management

DHCP principle and configuration

HCIP_ OSPF irregular area

JS - array de duplication in the array object case

Several precise order receiving methods suitable for fresh food wholesale industry
随机推荐
How to use annotations in word
Create a substrate private network
Buffer Overflow Vulnerability Lab
[game theory complete information static game] Nash equilibrium
[virt-manager]远程管理启动虚拟机时,鼠标飘逸的问题
京东商品详情接口,京东详情页接口,宝贝详情页接口,商品属性接口,商品信息查询,商品详细信息接口,h5详情,京东APP详情,京东api接口,京东历史价格数据接口代码对接分享
Dest0g3 520迎新賽
PHP PNG to webp
filebeat采集日志到ELK
Data accuracy problems caused by inconsistent data types during sum in MySQL
Daffodil upgrade (self idempotent)
ERP basic data Kingdee
sizeof、strlen求字符长度
Sizeof, strlen find character length
Methods of importing and exporting settings in Altium Designer
天猫商品详情接口,天猫商品优惠券接口,天猫api接口,天猫价格监控接口,天猫比价接口,品牌维权接口,天猫销量api接口,接口代码可对接数据分析业务,品牌维权,比价业务,行业分析业务接口代码分享
Microservice Project Construction II: database design
Wrap dynamically created child elements in dynamically created structures
[pychart pit stepping record] prompt after configuring remote operation, [errno 2] no such file or directory
Svg text stroke effect