当前位置:网站首页>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)})
边栏推荐
- MySQL indexes a field in a table
- 风控建模二:建模方案拟定
- 09 Spark on RDD 阶段划分
- Introduction to basic grammar and the foundation of freemarker
- 04 Spark on 读取外部数据分区策略(源码角度分析)
- (2022牛客多校五)G-KFC Crazy Thursday(二分+哈希/Manacher)
- (2022杭电多校三)1011.Taxi(曼哈顿最值+二分)
- 2022牛客多校六 M-Z-Game on grid(动态规划)
- Excel 2013 下拉为“快速分拆”调整为“填充序号”
- 生成二维码容错级别的问题
猜你喜欢
Modal dialog is used to implement the sign-in
关于vm虚拟机虚拟网络已禁用
【深度学习】TensorFlow学习之路二:ANN简介及TensorFlow实现
不躺平,然后做到极致,就是最大的“安全感”
WeChat applet wx:for loop output example
06 Spark on RDD序列化问题
深入理解计算系统第三章程序的机器级表达总结
(newcoder 15079)无关(容斥原理)
2022杭电多校六 1007-Shinobu loves trip(同余方程)
Introduction to Qt (5) - file operation, hotkey and mouse reading (implementation of txt window)
随机推荐
Get the current time before/after one day's date
php convert timestamp to just, minutes ago, hours ago, days ago format
线性筛求积性函数
linux环境安装mysql和使用中的常见问题
实用小技能:一键获取Harbor中镜像信息,快捷查询镜像
12 Spark on RDD 分区器
并发编程第4篇,锁的分类
并发编程第5篇,Synchronized的原理
TensorFlow learning path deep learning 】 【 3: gradient disappear \ explosion and solution
关于notepad++的js,xml插件安装
并发编程第10篇,CountDownLatch(计数器)和Semaphore(信号量)
03 Spark on 读取内部数据分区策略(源码角度分析)
(2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
PHP 类函数和对象函数
[Bug solution] ValueError: Object arrays cannot be loaded when allow_pickle=False
如何在Android中使用Realm数据库
2021 RoboCom 世界机器人开发者大赛-本科组(决赛)7-1绿色围栏(模拟)
(2022杭电多校四)1001-Link with Bracket Sequence II(区间动态规划)
Formatting of time objects
并发编程第9篇,Condition