当前位置:网站首页>Get the start and end dates of the current week
Get the start and end dates of the current week
2022-06-23 00:44:00 【Ziwei front end】
/**
* Get the start date and end date of the current week
* @param {string} startFormat Time format of Monday
* @param {string} endFormat Time format of Sunday
* @param {number} timestamp Timestamp of the week , If you don't pass in , The timestamp of the current time is used by default
* @returns {string, string} {startDate, endDate} Returned data
*/
export const getWeekStartAndEnd = (
startFormat: string,
endFormat: string,
timestamp?: number
): {
startDate: string,
endDate: string,
} => {
const oneDayTime = 1000 * 3600 * 24;
const nowDate = timestamp ? new Date(timestamp) : new Date();
const now = nowDate.getTime();
const nowDay = nowDate.getDay() === 0 ? 7 : nowDate.getDay();
const startDate = new Date(now - oneDayTime * (nowDay - 1));
const endDate = new Date(now + oneDayTime * (7 - nowDay));
return {
startDate: formatTime(startDate.getTime(), startFormat),
endDate: formatTime(endDate.getTime(), endFormat),
};
};边栏推荐
- Because I said: volatile is a lightweight synchronized, the interviewer asked me to go back and wait for the notice!
- Quelle est la structure et la façon dont les données sont stockées dans la base de données?
- Does qiniu school belong to a securities company? Is it safe to open an account?
- Introduction to the use of opencvsharp (C openCV) wechat QRcode decoding function (with source code attached)
- SAP ui5 application development tutorial 103 - how to consume third-party libraries in SAP ui5 applications
- 二叉树转字符串及字符串转二叉树
- Kunlundb query optimization (II) project and filter push down
- Yyds dry inventory solution sword finger offer: print the binary tree into multiple lines
- [PHP] PHP polymorphism
- Oracle ASM uses the CP command in asmcmd to perform remote replication
猜你喜欢

华为云如何实现实时音视频全球低时延网络架构【上】

Kunlundb backup and recovery

How to use enum data types

Isolation level of transaction system

cadence SPB17.4 - allegro - 優化指定單條電氣線折線連接角度 - 折線轉圓弧

如何入门机器学习?

SAP mm me27 create intra company sto order

Introduction to the use of opencvsharp (C openCV) wechat QRcode decoding function (with source code attached)

二叉树转字符串及字符串转二叉树

Have you stepped on these pits? Use caution when creating indexes on time type columns
随机推荐
掘地三尺搞定 Redis 与 MySQL 数据一致性问题
OSPF综合实验
[go] go language interface
华为云招募工业智能领域合作伙伴,强力扶持+商业变现
Typecho imitation of Lu Songsong's blog theme template / Technology Information blog theme template
BGP联邦综合实验
黄金etf持仓量如何算
flowable 全局监听 监听流程的启动和流程的结束
LINQ query
ROS1Noetic在Win11中安装记录
Daily question brushing record (I)
[PHP] PHP polymorphism
OpenCvSharp (C# OpenCV) 微信QRCode解码功能使用介绍(附源码)
OSPF experiment in mGRE environment
Kunlundb backup and recovery
OSPF comprehensive experiment
EasyCVR硬件盒子如何设置断电自启动
股票在哪个平台买比较安全呢?
打新债属于什么理财产品?
手机上券商开户哪个券商平台更好更安全,如果需要佣金低的怎么办