当前位置:网站首页>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
边栏推荐
- 470. Rand10() is implemented with rand7()
- stm32入门开发板选野火还是正点原子呢?
- 198. Looting - Dynamic Planning
- 48. 旋转图像
- 239. 滑动窗口最大值(困难)-单向队列、大顶堆-字节跳动高频题
- MySQL进阶学习之SQL优化【插入,主键,排序,分组,分页,计数】
- 1217_使用SCons生成目标文件
- 1217_ Generating target files using scons
- [batch change MySQL table and corresponding codes of fields in the table]
- 440. The k-th small number of dictionary order (difficult) - dictionary tree - number node - byte skipping high-frequency question
猜你喜欢
SystemVerilog(六)-变量
【Appium】通过设计关键字驱动文件来编写脚本
Hcip fifth experiment
PC电脑使用无线网卡连接上手机热点,为什么不能上网
Matlab / Simulink simulation of double closed loop DC speed regulation system
Why do some people say SCM is simple and I have to learn it so hard?
Collection of common SQL statements
Qt error: /usr/bin/ld: cannot find -lGL: No such file or directory
Future 用法详解
394. String decoding - auxiliary stack
随机推荐
Change Oracle to MySQL
470. Rand10() is implemented with rand7()
ros常用的函数——ros::ok(),ros::Rate,ros::spin()和ros::spinOnce()
Low code development platform sorting
1217_使用SCons生成目标文件
Allowed latency and side output
索引:手把手教你索引从零基础到精通使用
Using quartz under. Net core -- a simple trigger of [7] operation and trigger
Summary of common SQL statements
開期貨,開戶雲安全還是相信期貨公司的軟件?
[logical fallacy in life] Scarecrow fallacy and inability to refute are not proof
92. Reverse linked list II byte skipping high frequency question
ECMAScript history
In embedded system, must the program code in flash be moved to ram to run?
读《Software Engineering at Google》(15)
Use of five routing guards
Manually implement call, apply and bind functions
Manually implement simple promise and its basic functions
958. Complete binary tree test
[WPF binding 3] listview basic binding and data template binding