当前位置:网站首页>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,
};
};
边栏推荐
- Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
- 海外代理推荐
- [azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
- L2: current situation, prospects and pain points of ZK Rollup
- [interview arrangement] 0211 game engine server
- Jerry's fast pairing does not support canceling pairing [article]
- Google SEO external chain backlinks research tool recommendation
- 强化学习-学习笔记9 | Multi-Step-TD-Target
- OpenGL configuration vs2019
- cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
猜你喜欢
Restapi version control strategy [eolink translation]
cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
Implementation method of data platform landing
Ad domain group policy management
Use blocconsumer to build responsive components and monitor status at the same time
PDF文档签名指南
双塔模型的最强出装,谷歌又开始玩起“老古董”了?
你可曾迷茫?曾经的测试/开发程序员,懵懂的小菜C鸟升级......
【Azure微服务 Service Fabric 】如何转移Service Fabric集群中的种子节点(Seed Node)
[advanced MySQL] index details (I): index data page structure
随机推荐
Paint basic graphics with custompaint
【colmap】稀疏重建转为MVSNet格式输入
Anti climbing killer
Wechat official account oauth2.0 authorizes login and displays user information
Jerry's test box configuration channel [chapter]
Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]
Jerry's manual matching method [chapter]
OpenGL configure assimp
【JDBC Part 1】概述、获取连接、CRUD
Latest Android advanced interview questions summary, Android interview questions and answers
How to quickly check whether the opening area ratio of steel mesh conforms to ipc7525
Debugging and handling the problem of jamming for about 30s during SSH login
The function is really powerful!
NVR硬盘录像机通过国标GB28181协议接入EasyCVR,设备通道信息不显示是什么原因?
23. Merge K ascending linked lists -c language
怎样写一个增广矩阵到txt文件中
Backup tidb cluster to persistent volume
Jerry's power on automatic pairing [chapter]
SAR影像质量评估
VTOL in Px4_ att_ Control source code analysis [supplement]