当前位置:网站首页>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
边栏推荐
- flink 学习(十二)Allowed Lateness和 Side Output
- 01 - get to know the advantages of sketch sketch
- Solution of Navicat connecting Oracle library is not loaded
- Index: teach you index from zero basis to proficient use
- 402. Remove K digits - greedy
- 102. Sequence traversal of binary tree
- Double pointer advanced -- leetcode title -- container with the most water
- 239. 滑动窗口最大值(困难)-单向队列、大顶堆-字节跳动高频题
- 关于gcc输出typeid完整名的方法
- stm32入门开发板选野火还是正点原子呢?
猜你喜欢

flink 学习(十二)Allowed Lateness和 Side Output

Tdan over half

为什么有些人说单片机简单,我学起来这么吃力?

In embedded system, must the program code in flash be moved to ram to run?

PC电脑使用无线网卡连接上手机热点,为什么不能上网

关于gcc输出typeid完整名的方法
![Using quartz under. Net core -- general properties and priority of triggers for [5] jobs and triggers](/img/65/89473397da4217201eeee85aef3c10.png)
Using quartz under. Net core -- general properties and priority of triggers for [5] jobs and triggers

48. 旋转图像

Index: teach you index from zero basis to proficient use
![SQL optimization for advanced learning of MySQL [insert, primary key, sort, group, page, count]](/img/60/e4d47d458dd98a0c6ba51874e07c30.png)
SQL optimization for advanced learning of MySQL [insert, primary key, sort, group, page, count]
随机推荐
PC电脑使用无线网卡连接上手机热点,为什么不能上网
ASP. Net core JWT certification
The system cannot be started after AHCI is enabled
Node template engine (EJS, art template)
土地覆盖/利用数据产品下载
440. The k-th small number of dictionary order (difficult) - dictionary tree - number node - byte skipping high-frequency question
239. 滑动窗口最大值(困难)-单向队列、大顶堆-字节跳动高频题
C语言程序设计之函数的构造
Come out after a thousand calls
Manually implement simple promise and its basic functions
958. Complete binary tree test
Websocket (basic)
Open futures, open an account, cloud security or trust the software of futures companies?
Read software engineering at Google (15)
读《Software Engineering at Google》(15)
SQL optimization for advanced learning of MySQL [insert, primary key, sort, group, page, count]
Dry goods | how to extract thumbnails quickly?
Add drag and drop function to El dialog
92. 反转链表 II-字节跳动高频题
958. 二叉树的完全性检验