当前位置:网站首页>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
HelloJS
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)})边栏推荐
猜你喜欢

实用小技能:一键获取Harbor中镜像信息,快捷查询镜像

有了国产 DevOps 工具 ,还怕数字化转型成本高?
![[Bug solution] ValueError: Object arrays cannot be loaded when allow_pickle=False](/img/db/d5af96c3bcb645219bd14233d16157.png)
[Bug solution] ValueError: Object arrays cannot be loaded when allow_pickle=False

洛谷P4197 Peaks 线段树合并

51nod 2877熟练使用tarjan的知识

深入理解计算系统第三章程序的机器级表达总结

(2022牛客多校五)D-Birds in the tree(树形DP)

(2022牛客多校四)H-Wall Builder II(思维)

C语言中指针的介绍

(2022杭电多校三)1002-Boss Rush(状压DP+二分)
随机推荐
Porting ucos2 code from stm32 to GD32
51nod2614 小B爱旅行 (参考范艺杰代码 基本抄袭 太难了)
51nod 2882最短路 (树链剖分)
(newcoder 15079)无关(容斥原理)
跨域请求浏览器无法显示set-cookie,坑了我一晚上
不躺平,然后做到极致,就是最大的“安全感”
【深度学习】TensorFlow学习之路二:ANN简介及TensorFlow实现
Introduction to Qt (4) - Continuous playback of pictures (the use of two timers)
Excel 2013 下拉为“快速分拆”调整为“填充序号”
获取当前时间的前/后某一天的日期
mysql 高级知识【order by 排序优化】
WeChat applet wx:for loop output example
牛客多校2 G League of Legends
2022杭电多校六 1009-Map (巴那赫不动点)
Common problems in installing mysql in linux environment and using it
2021 RoboCom 世界机器人开发者大赛-本科组(决赛)7-4猛犸不上 Ban(最短路)
获取当前一周时间 不含当天
Formatting of time objects
Golang gorm 数据库连接,迁移,索引
Tp5 in cache cache, storage cell phone text message authentication code