当前位置:网站首页>获取当前时间的前/后某一天的日期
获取当前时间的前/后某一天的日期
2022-08-08 23:32:00 【聰籽】
/**
*获取当前时间的前/后某一天的日期
* @param val 必填 前/后某一天的数值,0表示今天的日期,-1表示当前时间的前一天日期,即昨天,以此类推负数可获取当前时间的前n天日期;1表示当前时间的后一天日期,即明天,以此类推。
* @param format 选填 格式 'mm'到小时 'ss'到秒,不填默认返回到天
* @param connector 选填 连接符 不填默认为 '-'
* @returns {string}
*/
getOneDate: function (val, format, connector) {
var that = this,
toDayTime = Date.now(),
otherDate = new Date(toDayTime + val * 86400000),
day = '';
day = new Date(otherDate.getFullYear() + '-' + (otherDate.getMonth() + 1) + '-' + otherDate.getDate()).getTime();
return that.timeFormat(day, format, connector);
},
边栏推荐
- 【瑞吉外卖】day04:员工分页查询、启用/禁用员工账号、编辑员工信息
- stm32 uses serial port to receive idle interrupt + dma to achieve variable length dma reception
- [PP-YOLOv2] Test a custom dataset
- 2022牛客多校六 B-Eezie and Pie (dfs)
- Low-Light Image Enhancement via a Deep Hybrid Network阅读札记
- (Codeforce 757)E. Bash Plays with Functions(积性函数)
- Master-slave delay reason and solution
- 13 Spark on RDD 全局累加器
- Introduction to Qt (4) - Continuous playback of pictures (the use of two timers)
- Kubernetes web网站无法访问
猜你喜欢
随机推荐
Low-Light Image Enhancement via a Deep Hybrid Network阅读札记
弹出PopupWindow后让背景变暗的方法
(2022杭电多校三)1002-Boss Rush(状压DP+二分)
51nod 2887 抓小偷 平面图最小割转换成最短路
Small program figure display banner
51nod 2877熟练使用tarjan的知识
LightningChart .NET 10.3.2 Crack 支持旧项目直接升级
【Verilog基础】关于芯片中信号串扰的理解
[YOLOv5] 6.0 environment construction (updated from time to time)
主从延迟原因及解决方案
启牛商学院靠不靠谱呢?证券账户开了安全吗
php convert timestamp to just, minutes ago, hours ago, days ago format
2022杭电多校五 C - Slipper (dijkstra+虚拟结点)
牛客练习赛88 D 克鲁斯卡尔重构树
Introduction to Qt (4) - Continuous playback of pictures (the use of two timers)
(2022牛客多校四)H-Wall Builder II(思维)
PMP考点有哪些啊?
13 Spark on RDD 全局累加器
【瑞吉外卖】day04:员工分页查询、启用/禁用员工账号、编辑员工信息
动手写prometheus的exporter-01-Gauge(仪表盘)