当前位置:网站首页>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
边栏推荐
- 双指针进阶--leetcode题目--盛最多水的容器
- flink 学习(十二)Allowed Lateness和 Side Output
- 剑指 Offer 03. 数组中重复的数字
- .Net Core3. 1 use razorengine NETCORE production entity generator (MVC web version)
- Sword finger offer 22 The penultimate node in the linked list - speed pointer
- MySQL进阶学习之SQL优化【插入,主键,排序,分组,分页,计数】
- For the space occupation of the software, please refer to the installation directory
- Using quartz under. Net core -- operation transfer parameters of [3] operation and trigger
- Kubernetes service discovery monitoring endpoints
- Self use learning notes - connectingstring configuration
猜你喜欢

102. Sequence traversal of binary tree

1217_使用SCons生成目标文件

470. Rand10() is implemented with rand7()

How to change input into text

Kubernetes 服务发现 监控Endpoints

Double pointer advanced -- leetcode title -- container with the most water

Learning record of uni app dark horse yougou project (Part 2)

Kubernetes service discovery monitoring endpoints

Qt 修改UI没有生效

JS parsing and execution process
随机推荐
122. 买卖股票的最佳时机 II-一次遍历
RPC核心概念理解
2. Electron's HelloWorld
【Appium】通过设计关键字驱动文件来编写脚本
Change Oracle to MySQL
Leak detection and vacancy filling (6)
Dry goods | how to extract thumbnails quickly?
flink 学习(十二)Allowed Lateness和 Side Output
958. 二叉树的完全性检验
402. 移掉 K 位数字-贪心
How to change input into text
41. 缺失的第一个正数
PC电脑使用无线网卡连接上手机热点,为什么不能上网
How to manually implement the mechanism of triggering garbage collection in node
Allowed latency and side output
索引:手把手教你索引从零基础到精通使用
Summary of common SQL statements
JVM class loading mechanism
Halo open source project learning (II): entity classes and data tables
41. The first missing positive number