当前位置:网站首页>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;
},边栏推荐
- 名次的确定
- Container concept and cloud native
- sizeof、strlen求字符长度
- [leetcode weekly race record] record of the 80th biweekly race
- Plane merging (matlab)
- Gtk+ programming example on page 115 - simplest progress bar 2 with steps to write GTK program using anjuta
- Dest0g3 520迎新赛
- Penetration problem (main directory, password explosion, database uploading Trojan horse)
- 第115页的gtk+编程例子——最简单的进度条2附带使用Anjuta写gtk程序的步骤
- WARNING:tornado.access:404 GET /favicon.ico (172.16.8.1) 1.84ms [附静态文件设置]
猜你喜欢

Wechat upload picture material interface

How about a well-known food material distribution information management system?

星巴克创始人:出于安全考量 或不再向非店内消费者开放“公厕”

关于redis使用分布式锁的封装工具类

Buffer Overflow Vulnerability Lab

CCNP_ Bt-ospf big experiment (1)

Start from scratch - implement the jpetstore website -1- establish the project framework and project introduction

MySQL parsing serialized fields

How can the small and medium-sized lighting industry make use of the digital transformation to stand out from the encirclement?

How to download and install stm32cubemx
随机推荐
Why do wholesalers use the order system
JS - max. of array cases
Microservice project construction III: automatic code generation
filebeat采集日志到ELK
How to efficiently manage commodities and inventory in the beverage wholesale industry
淘宝商品历史价格接口/商品历史价走势接口代码对接分享
Logstash failed to create queue
WARNING:tornado.access:404 GET /favicon.ico (172.16.8.1) 1.84ms [附静态文件设置]
File upload question type
Remote access and control
How to download and install stm32cubemx
How does the BD new tab plug-in log in?
【leetcode周赛记录】第80场双周赛记录
Wrap dynamically created child elements in dynamically created structures
Emotion handling skills
淘宝商品销量接口/淘宝商品销量监控接口/商品累计销量接口
Import the robot model built by SolidWorks into ROS
MySQL sorts according to the specified order of the specified fields
Live broadcast review | bas technology innovation exploration under active defense system
MySQL query exercise