当前位置:网站首页>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,
};
};
边栏推荐
- Reinforcement learning - learning notes 9 | multi step TD target
- [colmap] sparse reconstruction is converted to mvsnet format input
- TCP/IP 协议栈
- Ant destination multiple selection
- 如何选择合适的自动化测试工具?
- Validutil, "Rethinking the setting of semi supervised learning on graphs"
- 反爬通杀神器
- How to turn on win11 game mode? How to turn on game mode in win11
- 戴森官方直营店免费造型服务现已开放预约 先锋科技诠释护发造型理念,助力消费者解锁多元闪耀造型
- How to write an augmented matrix into TXT file
猜你喜欢
如何实现横版游戏中角色的移动控制
用语雀写文章了,功能真心强大!
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
Redis - basic use (key, string, list, set, Zset, hash, geo, bitmap, hyperloglog, transaction)
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?
#DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA
How to make agile digital transformation strategy for manufacturing enterprises
Ad domain group policy management
Overseas agent recommendation
你可曾迷茫?曾经的测试/开发程序员,懵懂的小菜C鸟升级......
随机推荐
Qt编写物联网管理平台39-报警联动
QT compile IOT management platform 39 alarm linkage
Use json Stringify() to realize deep copy, be careful, there may be a huge hole
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?
Dayu200 experience officer MPPT photovoltaic power generation project dayu200, hi3861, Huawei cloud iotda
Jerry's power on automatic pairing [chapter]
Codemail auto collation code of visual studio plug-in
Dbsync adds support for mongodb and ES
Write in front -- Talking about program development
Crawler (17) - Interview (2) | crawler interview question bank
Automatic classification of defective photovoltaic module cells in electronic images
How to write an augmented matrix into TXT file
2022 how to evaluate and select low code development platforms?
Preparing for the interview and sharing experience
Ad domain group policy management
Validutil, "Rethinking the setting of semi supervised learning on graphs"
MIT6.S081-Lab9 FS [2021Fall]
npm uninstall和rm直接删除的区别
cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
Build your own website (18)