当前位置:网站首页>Gets the time range of the current week
Gets the time range of the current week
2022-04-23 17:41:00 【Front Thoughts】
demand : The background needs to receive the time range of the current day !
Get the day of the week that the current day is :
var now = new Date();
var nowTime = now.getTime() ;
var day = now.getDay();
var oneDayTime = 24*60*60*1000 ;
Get the Monday of the current week :
var MondayTime = nowTime - (day-1)*oneDayTime ;
Get the Sunday of the current week :
var SundayTime = nowTime + (7-day)*oneDayTime ;
Initialization date time and parsing time format :
var monday = new Date(MondayTime).toISOString().slice(0,10).replace(/-/g,"/");
var sunday = new Date(SundayTime).toISOString().slice(0,10).replace(/-/g,"/");
Encapsulate the corresponding common.js Library to directly call , The callback returns the time of Monday Note the format of the conversion date :
function getFirstDayOfWeek (date) {
var day = date.getDay() || 7;
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1 - day);
};
版权声明
本文为[Front Thoughts]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230551157187.html
边栏推荐
- EasymodbusTCP之clientexample解析
- Webapi + form form upload file
- 239. 滑动窗口最大值(困难)-单向队列、大顶堆-字节跳动高频题
- Router object, route object, declarative navigation, programmed navigation
- Collection of common SQL statements
- 48. Rotate image
- SiteServer CMS5. 0 Usage Summary
- Learning record of uni app dark horse yougou project (Part 2)
- Leak detection and vacancy filling (6)
- XTask与Kotlin Coroutine的使用对比
猜你喜欢
1217_ Generating target files using scons
Simulation of infrared wireless communication based on 51 single chip microcomputer
STM32 entry development board choose wildfire or punctual atom?
01-初识sketch-sketch优势
双指针进阶--leetcode题目--盛最多水的容器
stm32入门开发板选野火还是正点原子呢?
编译原理 求first集 follow集 select集预测分析表 判断符号串是否符合文法定义(有源码!!!)
JVM class loading mechanism
394. 字符串解码-辅助栈
Comparison between xtask and kotlin coroutine
随机推荐
2. Electron's HelloWorld
[binary number] maximum depth of binary tree + maximum depth of n-ary tree
402. 移掉 K 位数字-贪心
470. 用 Rand7() 实现 Rand10()
JS interview question: FN call. call. call. Call (FN2) parsing
MySQL advanced index [classification, performance analysis, use, design principles]
开期货,开户云安全还是相信期货公司的软件?
[二叉数] 二叉树的最大深度+N叉树的最大深度
For the space occupation of the software, please refer to the installation directory
Why do some people say SCM is simple and I have to learn it so hard?
01 - get to know the advantages of sketch sketch
圆环回原点问题-字节跳动高频题
Advantages and disadvantages of several note taking software
Using quartz under. Net core -- preliminary understanding of [2] operations and triggers
Sword finger offer 03 Duplicate number in array
[ES6] promise related (event loop, macro / micro task, promise, await / await)
Exercise: even sum, threshold segmentation and difference (two basic questions of list object)
C dapper basically uses addition, deletion, modification and query transactions, etc
Ouvrir des contrats à terme, ouvrir des comptes en nuage ou faire confiance aux logiciels des sociétés à terme?
31. 下一个排列