当前位置:网站首页>js 获取两个时间段的时间组成数组
js 获取两个时间段的时间组成数组
2022-07-19 01:05:00 【Sunny_lxm】
getDayAll (starDay, endDay) {
var arr = [];
var dates = [];
// 设置两个日期UTC时间
var db = new Date(starDay);
var de = new Date(endDay);
// 获取两个日期GTM时间
var s = db.getTime() - 24 * 60 * 60 * 1000;
var d = de.getTime() - 24 * 60 * 60 * 1000;
// 获取到两个日期之间的每一天的毫秒数
for (var i = s; i <= d;) {
i = i + 24 * 60 * 60 * 1000;
arr.push(parseInt(i))
}
// 获取每一天的时间 YY-MM-DD
for( var j in arr ){
var time = new Date(arr[j]);
var year = time.getFullYear(time);
var mouth = (time.getMonth() + 1)>=10?(time.getMonth() + 1):('0'+(time.getMonth() + 1));
var day = time.getDate()>=10?time.getDate():('0'+time.getDate());
var YYMMDD = year + '-' + mouth + '-' + day;
dates.push(YYMMDD)
}
return dates
}
var dataAll = this.getDayAll('2020-01-01','2020-02-01');
console.log(dataAll)
边栏推荐
- 靶机无法获得IP地址, 该怎么办?
- STM32状态机编程实例——全自动洗衣机(上)
- Award winning research | what does the perfect ar development platform look like to make virtual reality?
- 洛谷每日三题之第六天
- WTO MC12达成“1+4”成果 推动全球疫后经济复苏
- Tutoriel de requête SQL pour la science des données avec mon serveur SQL
- codeforces每日5题(均1500)-第十九天
- II - 01day: object index understanding, this point on the object, object conversion to string, function pre parsing, arguments The usage of callee,
- Luogu p1016 [noip1999 improvement group] traveller's budget solution
- JVM knowledge map (under update)
猜你喜欢
[C exercise] arrow pattern
468-82(142、199、509、70、746)
MySQL 事务
DOM operation of JS -- event object
Activity.onStop() 延迟10秒?检测、定位、修复它~
WTO MC12 achieves "1+4" achievements to promote global post pandemic economic recovery
VLAN aggregation
【自校正控制】递推最小二乘法
Shell basic command operations (SEQ sequence, TR conversion)
【翻译】介绍一下Opta。Rails上的Terraform
随机推荐
[self learning] - how to make the dialogue robot stronger and stronger?
有奖调研 | 让虚拟照入现实的完美AR开发平台长什么样?
[Niuke brush questions] / * daily four programming questions to share*/
B树 B+树
The knowledge of five elements and eight trigrams
Grass is flying all over the sky
Is it safe to open Huatai account on your mobile phone?
ShareIt group was ranked among the top 4 companies in the Indonesian market
Time flies.
shell查询prometheus数据
The LAAS protocol elephant of defi 2.0 is the key to revitalizing the development of defi track
Conditions and details of polar coordinate substitution for solving the limit of multivariate functions with high numbers
MySQL password modification error 1064 (42000):
mTD-SCDMA与TD-LTE双网络垂直切换matlab仿真
DeFi 2.0的LaaS协议Elephant,重振DeFi赛道发展的关键
Leetcode exercise - Sword finger offer 32 - III. print binary tree III from top to bottom
JS的DOM操作——事件
SHAREit Group荣登印尼市场热门公司榜单TOP4
线程与进程------理论篇
The difference between overloading and rewriting