当前位置:网站首页>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,
};
};
边栏推荐
- Win11时间怎么显示星期几?Win11怎么显示今天周几?
- MIT6.S081-Lab9 FS [2021Fall]
- Win11U盘不显示怎么办?Win11插U盘没反应的解决方法
- Jerry's configuration of TWS cross pairing [article]
- Welcome to CSDN markdown editor
- DNS series (I): why does the updated DNS record not take effect?
- operator
- SAR image quality evaluation
- ByteDance senior engineer interview, easy to get started, fluent
- Code of "digital image processing principle and Practice (matlab version)" part2[easy to understand]
猜你喜欢

The latest Android interview collection, Android video extraction audio

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

【Azure微服务 Service Fabric 】因证书过期导致Service Fabric集群挂掉(升级无法完成,节点不可用)

Customer case | China law network, through observing the cloud, greatly shortens the time of fault location

2022 how to evaluate and select low code development platforms?

Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission

Px4 autonomous flight

Why can't win11 display seconds? How to solve the problem that win11 time does not display seconds?

The whole network "chases" Zhong Xuegao

Redis - basic use (key, string, list, set, Zset, hash, geo, bitmap, hyperloglog, transaction)
随机推荐
How to turn on win11 game mode? How to turn on game mode in win11
Time standard library
Latest Android advanced interview questions summary, Android interview questions and answers
cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
Navicat connect 2002 - can't connect to local MySQL server through socket '/var/lib/mysql/mysql Sock 'solve
Embedded development: how to choose the right RTOS for the project?
Ant destination multiple selection
你可曾迷茫?曾经的测试/开发程序员,懵懂的小菜C鸟升级......
Kaggle-Titanic
[advanced MySQL] index details (I): index data page structure
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
Win11U盘不显示怎么办?Win11插U盘没反应的解决方法
Reinforcement learning - learning notes 9 | multi step TD target
Tsconfig of typescript TS basics JSON configuration options
Jerry's manual matching method [chapter]
How to integrate Google APIs with Google's application system (1) -introduction to Google APIs
Use partial derivatives to display normals in unity
PKPM 2020软件安装包下载及安装教程
解决uni-app中uni.request发送POST请求没有反应。
建立自己的网站(18)