当前位置:网站首页>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
边栏推荐
猜你喜欢
![MySQL advanced index [classification, performance analysis, use, design principles]](/img/96/b031868602a7b8ba4edd0d74c843b3.png)
MySQL advanced index [classification, performance analysis, use, design principles]

Understanding of RPC core concepts

Exercise: even sum, threshold segmentation and difference (two basic questions of list object)

958. 二叉树的完全性检验
![Using quartz under. Net core -- operation transfer parameters of [3] operation and trigger](/img/4e/2161fc448f4af71d9b73b7de64a17f.png)
Using quartz under. Net core -- operation transfer parameters of [3] operation and trigger
![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
MySQL installation
![[difference between Oracle and MySQL]](/img/90/6d030a35692fa27f1a7c63985af06f.png)
[difference between Oracle and MySQL]

ASP. Net core JWT certification

92. Reverse linked list II byte skipping high frequency question
随机推荐
Node template engine (EJS, art template)
Use of todesk remote control software
2021 Great Wall Cup WP
tidb-server 的配置文件在哪里?
JS interview question: FN call. call. call. Call (FN2) parsing
Using quartz under. Net core -- a simple trigger of [7] operation and trigger
122. 买卖股票的最佳时机 II-一次遍历
41. 缺失的第一个正数
ES6 new method
Learning record of uni app dark horse yougou project (Part 2)
ASP. Net core JWT certification
古代埃及希腊,数学用的什么进制
102. Sequence traversal of binary tree
索引:手把手教你索引从零基础到精通使用
MySQL installation
关于gcc输出typeid完整名的方法
Add drag and drop function to El dialog
双闭环直流调速系统matlab/simulink仿真
92. 反转链表 II-字节跳动高频题
Model problems of stock in and stock out and inventory system