当前位置:网站首页>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,
};
};
边栏推荐
- Jerry's fast pairing does not support canceling pairing [article]
- PDF文档签名指南
- Node:504 error reporting
- The maximum number of meetings you can attend [greedy + priority queue]
- SAR image quality evaluation
- ByteDance senior engineer interview, easy to get started, fluent
- Use json Stringify() to realize deep copy, be careful, there may be a huge hole
- 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?
- How polardb-x does distributed database hotspot analysis
- An in-depth understanding of fp/fn/precision/recall
猜你喜欢

Win11游戏模式怎么开启?Win11开启游戏模式的方法

Open source OA development platform: contract management user manual

【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
![Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]](/img/14/1c8a70102c106f4631853ed73c4d82.png)
Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]

Ad domain group policy management

Crawler (17) - Interview (2) | crawler interview question bank

Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted

Index summary (assault version)

South China x99 platform chicken blood tutorial

TCP/IP 协议栈
随机推荐
客户案例|华律网,通过观测云大幅缩短故障定位时间
如何选择合适的自动化测试工具?
Reinforcement learning - learning notes 9 | multi step TD target
Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
Backup tidb cluster to persistent volume
How to make agile digital transformation strategy for manufacturing enterprises
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
[advanced MySQL] index details (I): index data page structure
Matplotlib drawing interface settings
Time standard library
Kaggle-Titanic
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?
null == undefined
EasyCVR配置中心录像计划页面调整分辨率时的显示优化
怎样写一个增广矩阵到txt文件中
嵌入式开发:如何为项目选择合适的RTOS?
MIT6.S081-Lab9 FS [2021Fall]
三元表达式、各生成式、匿名函数
Pdf document signature Guide
Ant destination multiple selection