


How to use js to get each time point based on the start time and end time
The effect of this blog (demo address included):
test.html file code
<html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="./js/jquery-2.1.1.js"></script></head><body><p class="getDay"><a href="#">获取2017-08-28到2017-09-08该段时间内的所有以天为单位的日期</a></p><p class="getWeek"><a href="#">获取2017-06-05到2017-09-04该段时间内的所有以周一为单位的日期</a></p><p class="month"><a href="#">获取2016-06-01到2017-09-01该段时间内的所有以月为单位的日期</a></p><p class="year"><a href="#">获取2003-01-01到2017-01-01该段时间内的所有以年为单位的日期</a></p></body><script> $(document).ready(function () { $(".getDay").click(function () { alert(getDayAll("2017-08-28","2017-09-08")); }) $(".getWeek").click(function () { alert(getWeekAll("2017-06-05","2017-09-04")); }) $(".month").click(function () { alert(getMonthAll("2016-06-01","2017-09-01")); }) $(".year").click(function () { alert(getYearAll("2003-01-0","2017-01-01")); }) }) Date.prototype.format=function (){ var s=''; s+=this.getFullYear()+'-'; // 获取年份。 s+=(this.getMonth()+1)+"-"; // 获取月份。 s+= this.getDate(); // 获取日。 return(s); // 返回日期。 }; //按日查询 function getDayAll(begin,end){ var dateAllArr = new Array(); var ab = begin.split("-"); var ae = end.split("-"); var db = new Date(); db.setUTCFullYear(ab[0], ab[1]-1, ab[2]); var de = new Date(); de.setUTCFullYear(ae[0], ae[1]-1, ae[2]); var unixDb=db.getTime(); var unixDe=de.getTime(); for(var k=unixDb;k<=unixDe;){ dateAllArr.push((new Date(parseInt(k))).format().toString()); k=k+24*60*60*1000; } return dateAllArr; } //按周查询 function getWeekAll(begin,end){ var dateAllArr = new Array(); var ab = begin.split("-"); var ae = end.split("-"); var db = new Date(); db.setUTCFullYear(ab[0], ab[1]-1, ab[2]); var de = new Date(); de.setUTCFullYear(ae[0], ae[1]-1, ae[2]); var unixDb=db.getTime(); var unixDe=de.getTime(); for(var k=unixDb;k<=unixDe;){ dateAllArr.push((new Date(parseInt(k))).format().toString()); k=k+7*24*60*60*1000; } return dateAllArr; } function getMonthAll(begin,end) { var d1 = begin; var d2 = end; var dateArry = new Array(); var s1 = d1.split("-"); var s2 = d2.split("-"); var mCount = 0; if (parseInt(s1[0]) < parseInt(s2[0])) { mCount = (parseInt(s2[0]) - parseInt(s1[0])) * 12 + parseInt(s2[1]) - parseInt(s1[1])+1; } else { mCount = parseInt(s2[1]) - parseInt(s1[1])+1; } if (mCount > 0) { var startM = parseInt(s1[1]); var startY = parseInt(s1[0]); for (var i = 0; i < mCount; i++) { if (startM < 12) { dateArry[i] = startY + "-" + (startM>9 ? startM : "0" + startM); startM += 1; } else { dateArry[i] = startY + "-" + (startM > 9 ? startM : "0" + startM); startM = 1; startY += 1; } } } return dateArry; } function getYearAll(begin,end) { var d1 = begin; var d2 = end; var dateArry = new Array(); var s1 = d1.split("-"); var s2 = d2.split("-"); var mYearCount = parseInt(s2[0]) - parseInt(s1[0])+1; var startY = parseInt(s1[0]); for (var i = 0; i < mYearCount;i++) { dateArry[i] = startY; startY += 1; } return dateArry; } </script> </html>
The above is the detailed content of How to use js to get each time point based on the start time and end time. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

On the Douyin platform, many users are eager to obtain level certification, and the level 10 light sign shows the user's influence and recognition on Douyin. This article will delve into the price of Douyin’s level 10 light boards and the time it takes to reach this level to help users better understand the process. 1. How much does a level 10 Douyin light sign cost? The price of Douyin's 10-level light signs will vary depending on market fluctuations and supply and demand. The general price ranges from a few thousand yuan to ten thousand yuan. This price mainly includes the cost of the light sign itself and possible service fees. Users can purchase level 10 light signs through Douyin’s official channels or third-party service agencies, but they should pay attention to legal channels when purchasing to avoid false or fraudulent transactions. 2. How many days does it take to create a level 10 fan sign? Reach level 10 light sign

Xiaohongshu, a platform full of life and knowledge sharing, allows more and more creators to express their opinions freely. In order to get more attention and likes on Xiaohongshu, in addition to the quality of content, the time of publishing works is also crucial. So, how to set the time for Xiaohongshu to publish works? 1. How to set the time for publishing works on Xiaohongshu? 1. Understand the active time of users. First, it is necessary to clarify the active time of Xiaohongshu users. Generally speaking, 8 pm to 10 pm and weekend afternoons are the times when user activity is high. However, this time period will also vary depending on factors such as audience group and geography. Therefore, in order to better grasp the active period of users, it is recommended to conduct a more detailed analysis of the behavioral habits of different groups. By understanding users’ lives

Players can experience the main plot of the game and collect game achievements when playing in Elden's Circle. Many players don't know how long it takes to clear Elden's Circle. The player's clearance process is 30 hours. How long does it take to clear the Elden Ring? Answer: 30 hours. 1. Although this 30-hour clearance time does not refer to a master-like speed pass, it also omits a lot of processes. 2. If you want to get a better game experience or experience the complete plot, then you will definitely need to spend more time on the duration. 3. If players collect them all, it will take about 100-120 hours. 4. If you only take the main line to brush BOSS, it will take about 50-60 hours. 5. If you want to experience it all: 150 hours of base time.

Each season of Teamfight Tactics lasts about three months. Currently, the US test server of Teamfight Tactics S11 season will be updated and launched on March 7. Teamfight Tactics and Golden Shovel will be updated and launched on March 21. It is speculated that the S11 season It will probably end in early July. When will TFT S11 end? Answer: Early July. 1. It is speculated that the S11 season will end in early July. The specific end date needs to wait for the official announcement. 2. Each season of Teamfight Tactics lasts about three months. 3. The US test server of Teamfight Tactics S11 season will be updated and launched on March 7, and Teamfight Tactics and Golden Shovel will be updated and launched on March 21. 4. A new gameplay mechanism will be added to the S11 season, and more than 20 new Ornn artifacts will be added.

Detailed explanation of Linux file time viewing techniques In Linux systems, file time information is very important for file management and tracking changes. The Linux system records file change information through three main time attributes, namely access time (atime), modification time (mtime) and change time (ctime). This article details how to view and manage this file time information, and provides specific code examples. 1. Check the file time information by using the ls command with the parameter -l to list the files.

When we use computers, we will inevitably encounter a lot of problems that keep running in the background, which slows down the system. At this time, is there a shortcut key to end the background running in win11? In fact, we can only open the task manager with the shortcut key and then close it. Backstage. Shortcut keys to end background running in win11: 1. First, we press the "ctrl+shift+esc" shortcut key combination on the keyboard to open the task manager page. 2. In the Task Manager page, use the mouse to click and select the "Name" button option. 3. After the page jumps, we can directly see all the "background processes" currently running. 4. According to actual needs, we select the background that we want to close, and click "End Task" in the lower right corner of the option.

Many friends encounter certain software getting stuck when using their computers. If the computer cannot move, you need to call up the task manager to end the process. After calling it out, how to use the shortcut keys to end the task? The simplest is to delete, and there are other methods. Let’s take a look. Take a look. How to use the shortcut keys for ending tasks in Task Manager How to use the shortcut keys for Task Manager: 1. Key combination "Ctrl+Shift+ESC". 2. Key combination "Ctrl+Alt+Delete". Shortcut keys for ending tasks 1. Select the task to be ended and click "Delete". 2. Select the task that needs to be ended and press the key combination "alt+e".

Many users are not sure how to adjust the time of the gshock watch. The overall method is relatively simple. Here is a detailed introduction to the adjustment method of the gshock watch. Users who do not know how to operate can refer to it. How to adjust the time on a gshock watch 1. First label these buttons according to ABCD. A key: It can be understood as the exit key, usually used together with the C key. The B key and the D key can be understood as: plus and minus keys, which are the adjustment keys. For example, if it is 13 o'clock now, press the D key when it reaches 14 o'clock. The C key is the mode key. You can switch modes by pressing it. Generally, the mode key of a watch is in the lower left corner and has the word "mode" in English. Operation method 1. First we need to adjust the watch to the
