当前位置:网站首页>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,
};
};
边栏推荐
- Reptile combat (VII): pictures of the king of reptiles' heroes
- The strongest installation of the twin tower model, Google is playing "antique" again?
- DNS series (I): why does the updated DNS record not take effect?
- OpenGL homework - Hello, triangle
- Jerry's about TWS pairing mode configuration [chapter]
- [advanced MySQL] index details (I): index data page structure
- [开源] .Net ORM 访问 Firebird 数据库
- Welcome to CSDN markdown editor
- Navicat connect 2002 - can't connect to local MySQL server through socket '/var/lib/mysql/mysql Sock 'solve
- QT compile IOT management platform 39 alarm linkage
猜你喜欢
cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
Matplotlib drawing interface settings
用语雀写文章了,功能真心强大!
[advanced MySQL] index details (I): index data page structure
operator
[azure microservice service fabric] how to transfer seed nodes in the service fabric cluster
Why can't win11 display seconds? How to solve the problem that win11 time does not display seconds?
Jerry's manual matching method [chapter]
Embedded development: how to choose the right RTOS for the project?
随机推荐
Attitude estimation (complementary filtering)
Have you ever been confused? Once a test / development programmer, ignorant gadget C bird upgrade
The function is really powerful!
Navicat connect 2002 - can't connect to local MySQL server through socket '/var/lib/mysql/mysql Sock 'solve
OpenGL configuration vs2019
[open source] Net ORM accessing Firebird database
Talk about relational database and serverless
怎样写一个增广矩阵到txt文件中
How to quickly check whether the opening area ratio of steel mesh conforms to ipc7525
Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold
Build your own website (18)
应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设
Index summary (assault version)
Wechat official account oauth2.0 authorizes login and displays user information
[开源] .Net ORM 访问 Firebird 数据库
Overseas agent recommendation
Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
Preparing for the interview and sharing experience
Jerry's manual matching method [chapter]
SAR影像质量评估