当前位置:网站首页>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,
};
};
边栏推荐
- Oracle advanced (VI) Oracle expdp/impdp details
- Relationship between URL and URI
- Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
- ByteDance senior engineer interview, easy to get started, fluent
- Jerry's manual matching method [chapter]
- L'enregistreur de disque dur NVR est connecté à easycvr par le Protocole GB 28181. Quelle est la raison pour laquelle l'information sur le canal de l'appareil n'est pas affichée?
- 使用 BlocConsumer 同时构建响应式组件和监听状态
- Google SEO external chain backlinks research tool recommendation
- 为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
- 强化学习-学习笔记9 | Multi-Step-TD-Target
猜你喜欢
VTOL in Px4_ att_ Control source code analysis [supplement]
[JDBC Part 1] overview, get connection, CRUD
使用 BlocConsumer 同时构建响应式组件和监听状态
Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
Win11U盘不显示怎么办?Win11插U盘没反应的解决方法
Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
Jenkins user rights management
【Azure微服务 Service Fabric 】如何转移Service Fabric集群中的种子节点(Seed Node)
Implementation method of data platform landing
随机推荐
Reinforcement learning - learning notes 9 | multi step TD target
ByteDance senior engineer interview, easy to get started, fluent
[开源] .Net ORM 访问 Firebird 数据库
Use blocconsumer to build responsive components and monitor status at the same time
ByteDance Android interview, summary of knowledge points + analysis of interview questions
OpenGL configuration vs2019
null == undefined
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
[interview arrangement] 0211 game engine server
OpenGL jobs - shaders
客户案例|华律网,通过观测云大幅缩短故障定位时间
Win11如何解禁键盘?Win11解禁键盘的方法
反爬通杀神器
Use json Stringify() to realize deep copy, be careful, there may be a huge hole
Win11U盘不显示怎么办?Win11插U盘没反应的解决方法
Debugging and handling the problem of jamming for about 30s during SSH login
The latest Android interview collection, Android video extraction audio
Reinforcement learning - learning notes 9 | multi step TD target
Redis - basic use (key, string, list, set, Zset, hash, geo, bitmap, hyperloglog, transaction)
[open source] Net ORM accessing Firebird database