当前位置:网站首页>获取当前一周的时间范围
获取当前一周的时间范围
2022-04-23 05:53:00 【Front 小思】
需求:后台需要接收的是当前一天所在的时间范围!
获取当前所在的一天是周几:
var now = new Date();
var nowTime = now.getTime() ;
var day = now.getDay();
var oneDayTime = 24*60*60*1000 ;
获取当前所在的一周的周一:
var MondayTime = nowTime - (day-1)*oneDayTime ;
获取当前所在的一周的周日:
var SundayTime = nowTime + (7-day)*oneDayTime ;
初始化日期时间及解析时间格式:
var monday = new Date(MondayTime).toISOString().slice(0,10).replace(/-/g,"/");
var sunday = new Date(SundayTime).toISOString().slice(0,10).replace(/-/g,"/");
封装对应的common.js库来直接调用,回调的返回周一的时间的 注意转化日期的格式:
function getFirstDayOfWeek (date) {
var day = date.getDay() || 7;
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1 - day);
};
版权声明
本文为[Front 小思]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45788691/article/details/120777917
边栏推荐
- Introduction to nonparametric camera distortion model
- TP download folder, compress folder and download
- 微信小程序之点击取消,返回上页,修改上页的参数值,let pages=getCurrentPages() let prevPage=pages[pages.length - 2] // 上一页的数据
- Krypton binary
- [UDS unified diagnosis service] IV. typical diagnosis service (1) - diagnosis and communication management function unit
- Collection of practical tips for C language (continuously updated)
- 2020 Jiangsu Collegiate Programming Contest-A.Array
- [stepping on the pit] MELD in win11 wsl2 cannot be used normally. Problem repair
- js获取链接?后边的参数名称或者值,根据url ?后的参数做判断
- C语言 #和##的使用
猜你喜欢
js根据名字将数组对象中名字相同的项组成一个相同的数组
Introduction to nonparametric camera distortion model
CUDA project encountered a series of compilation problems after changing the environment (computer)
记第一次使用阿里字体图标库
VHDL-任意分频器(50%占空比)
[UDS unified diagnostic service] II. Network layer protocol (1) - overview and functions of network layer
[UDS unified diagnostic service] IV. typical diagnostic service (5) - function / component test function unit (routine function unit 0x31)
MOS管特性和导通过程
C语言实用小技巧合集(持续更新)
基于SSD的物体检测案例实现
随机推荐
FOC single resistance sampling position loop control servo motor
Assembler 32-bit unsigned addition calculator
[UDS unified diagnosis service] i. diagnosis overview (3) - ISO 15765 architecture
Palindromic Primes
死区时间的分析与设置
C语言代码规范
Collection of practical tips for C language (continuously updated)
js根据名字将数组对象中名字相同的项组成一个相同的数组
2022LDU寒假训练-程序补丁
C language advanced notes 3
Notes on advanced points of C language 2
C language code specification
锚点定位——如何设置锚点居页面顶部距离,锚点定位并距离顶部一定偏移
Incremental update of client software
[UDS unified diagnosis service] i. diagnosis overview (1) - diagnosis overview
SDOI2009-HH的项链
Detailed explanation and application of PN junction and diode principle
Notes on advanced points of C language 5
Qt 给应用程序加图标
C语言结构体指定初始化