当前位置:网站首页>Get the week start time and week end time of the current date
Get the week start time and week end time of the current date
2022-07-07 22:18:00 【Belden wind】
Native js Get the start time and end time of the week
/** * Get the week start time and week end time of the current date * @example * getWeekDate(new Date()) =>{ weekStartDate: new Date(), weekEndDate: new Date() } */
export const getWeekDate = (date: Date, format?: (date: Date) => string) => {
const nowDayOfWeek = date.getDay() - 1; // Today is the third day of the week
const nowDay = date.getDate(); // Current day
const nowMonth = date.getMonth(); // The current month
const nowYear = date.getFullYear(); // The current year
const weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
const weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
return {
weekStartDate: format ? format(weekStartDate) : weekStartDate,
weekEndDate: format ? format(weekEndDate) : weekEndDate,
};
};
边栏推荐
- Validutil, "Rethinking the setting of semi supervised learning on graphs"
- Embedded development: how to choose the right RTOS for the project?
- How to choose the appropriate automated testing tools?
- Navicat connect 2002 - can't connect to local MySQL server through socket '/var/lib/mysql/mysql Sock 'solve
- 【colmap】稀疏重建转为MVSNet格式输入
- ByteDance senior engineer interview, easy to get started, fluent
- Song list 11111
- How to realize the movement control of characters in horizontal game
- MIT6.S081-Lab9 FS [2021Fall]
- 【JDBC Part 1】概述、获取连接、CRUD
猜你喜欢
Px4 autonomous flight
强化学习-学习笔记9 | Multi-Step-TD-Target
Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
反爬通杀神器
[azure microservice service fabric] the service fabric cluster hangs up because the certificate expires (the upgrade cannot be completed, and the node is unavailable)
Wechat official account oauth2.0 authorizes login and displays user information
EasyCVR配置中心录像计划页面调整分辨率时的显示优化
Dry goods sharing | devaxpress v22.1 original help document download collection
PKPM 2020软件安装包下载及安装教程
随机推荐
2022 how to evaluate and select low code development platforms?
Implementation method of data platform landing
Oracle advanced (VI) Oracle expdp/impdp details
The whole network "chases" Zhong Xuegao
Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold
Node:504 error reporting
戴森官方直营店免费造型服务现已开放预约 先锋科技诠释护发造型理念,助力消费者解锁多元闪耀造型
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
[open source] Net ORM accessing Firebird database
How to integrate Google APIs with Google's application system (1) -introduction to Google APIs
Use json Stringify() to realize deep copy, be careful, there may be a huge hole
Backup tidb cluster to persistent volume
MIT6.S081-Lab9 FS [2021Fall]
PDF文档签名指南
Google SEO external chain backlinks research tool recommendation
Jenkins user rights management
NVR hard disk video recorder is connected to easycvr through the national standard gb28181 protocol. What is the reason why the device channel information is not displayed?
Main functions of OS, Sys and random Standard Libraries
Overseas agent recommendation
【Azure微服务 Service Fabric 】如何转移Service Fabric集群中的种子节点(Seed Node)