当前位置:网站首页>Get the start time and end time of the current month half a year ago
Get the start time and end time of the current month half a year ago
2022-08-08 23:38:00 【Satoshi seeds】
HTML
Hello
JS
function getWhatDate(str) { //A parameter is passed as the start time, and no parameter is passed as the end time// Get timestamp and data period // Start time, format yyyy - MM - dd HH: mm: ssvar nowdate = new Date();var halfYearDate = new Date(Date.now() - (365 / 2 * 24 * 3600 * 1000));if (str) {timeDate = getdate(halfYearDate, str)} else {timeDate = getdate(nowdate)}function getdate(date, str) {// Y = date.getFullYear() + '-';// M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';// D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';// h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';// m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';// s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()Y = date.getFullYear();M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()if (str) {if (M <= 11) {return Y + '-' + (M + 1) + '-' + '01 00:00:00';} else {return (Y + 1) + '-' + '01-01 00:00:00';}} else {return Y + '-' + M + '-' + D + ' 23:59:59';}}return timeDate}$("button").on("click",function(){var time = getWhatDate('start')var end = getWhatDate()console.log(time,end)})
边栏推荐
- [Bug solution] ValueError: Object arrays cannot be loaded when allow_pickle=False
- 51nod1656 合并trie树
- (2022牛客多校三)J-Journey(dijkstra)
- pytorch常用代码
- 最小生成树prim 求得 树上两点之间的最大最小值
- 可以在易方达基金上买基金吗,安全吗
- 实用小技能:一键获取Harbor中镜像信息,快捷查询镜像
- WeChat applet develops some function usage methods
- (2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
- Excel 2013 下拉为“快速分拆”调整为“填充序号”
猜你喜欢
随机推荐
stm32 uses serial port to receive idle interrupt + dma to achieve variable length dma reception
09 Spark on RDD 阶段划分
机器学习建模高级用法!构建企业级AI建模流水线
最常用正则表达式
PMP考点有哪些啊?
【瑞吉外卖】day04:员工分页查询、启用/禁用员工账号、编辑员工信息
【深度学习】TensorFlow学习之路一:TensorFlow简介及线性回归、逻辑回归实现
获取一星期前的时间 n-1 为含当天 一周7天 7-1
域前置通信过程和溯源思路
Small program figure display banner
抽象内部类
12 Spark on RDD 分区器
Excel 2013 下拉为“快速分拆”调整为“填充序号”
Kubernetes web网站无法访问
Common problems in installing mysql in linux environment and using it
04 Spark on 读取外部数据分区策略(源码角度分析)
2022杭电多校六 1009-Map (巴那赫不动点)
51nod 2887 抓小偷 平面图最小割转换成最短路
PHP 类函数和对象函数
启牛商学院靠不靠谱呢?证券账户开了安全吗