/*
* 获取当前年月日
* */
export function nowDate() {const loadYear = new Date().getFullYear()let loadMonth = new Date().getMonth() + 1let loadDay = new Date().getDate()if (loadMonth >= 1 && loadMonth <= 9) {loadMonth = '0' + loadMonth}if (loadDay >= 0 && loadDay <= 9) {loadDay = '0' + loadDay}const date = loadYear + '-' + loadMonth + '-' + loadDayreturn date
}
/*
* 获取前三个月
* */
export function beforeThree() {const dates = new Date()dates.setMonth(dates.getMonth() - 3)var pastMonth = dates.getMonth() + 1var pastDay = dates.getDate()if (pastMonth >= 1 && pastMonth <= 9) {pastMonth = '0' + pastMonth}if (pastDay >= 0 && pastDay <= 9) {pastDay = '0' + pastDay}const endDate = dates.getFullYear() + '-' + pastMonth + '-' + pastDayreturn endDate
}
/*
* 最近一月
* */
export function oneMonth() {const dates = new Date()dates.setMonth(dates.getMonth() - 1)var pastMonth = dates.getMonth() + 1var pastDay = dates.getDate()if (pastMonth >= 1 && pastMonth <= 9) {pastMonth = '0' + pastMonth}if (pastDay >= 0 && pastDay <= 9) {pastDay = '0' + pastDay}const endDate = dates.getFullYear() + '-' + pastMonth + '-' + pastDayreturn endDate
}
/*
* 最近半年
* */
export function haflYear() {// 先获取当前时间var curDate = (new Date()).getTime()// 将半年的时间单位换算成毫秒var halfYear = 365 / 2 * 24 * 3600 * 1000// 半年前的时间(毫秒单位)var pastResult = curDate - halfYear// 日期函数,定义起点为半年前var pastDate = new Date(pastResult)var pastYear = pastDate.getFullYear()var pastMonth = pastDate.getMonth() + 1var pastDay = pastDate.getDate()if (pastMonth >= 1 && pastMonth <= 9) {pastMonth = '0' + pastMonth}if (pastDay >= 0 && pastDay <= 9) {pastDay = '0' + pastDay}var endDate = pastYear + '-' + pastMonth + '-' + pastDayreturn endDate
}
/*
* 最近一年
* */
export function reactYear() {var nowDate = new Date()var dates = new Date(nowDate)dates.setDate(dates.getDate() - 365)var seperator1 = '-'var year = dates.getFullYear()var month = dates.getMonth() + 1var strDate = dates.getDate()if (month >= 1 && month <= 9) {month = '0' + month}if (strDate >= 0 && strDate <= 9) {strDate = '0' + strDate}var currentdate = year + seperator1 + month + seperator1 + strDatereturn currentdate
}
/*
* 当前月末日期
* */
export function endMonth(loadYear, loadMonth) {const d = new Date(loadYear, Number(loadMonth) + 1, 0)const endDay = d.getDate()const endDate = loadYear + '-' + (Number(loadMonth) + 1) + '-' + endDayreturn endDate
}/*** 当前日期+1*/
export function getNextDay() {const date = new Date();date.setTime(date.getTime()+24*60*60*1000);const nextDay = {year: date.getFullYear(),month: date.getMonth() + 1,day: date.getDate()}return nextDay
}

Vue 获取最近一个月,前三个月, 最近半年,最近一年, 当前月末日期相关推荐

  1. date js 半年_moment.js 搜索栏获取最近一周,一个月,三个月,半年,一年时间

    统计时间 label: '统计时间', name: 'countTime', type: 'select', data: [ { value: '0', text: '最近一周' }, { value ...

  2. moment.js 搜索栏获取最近一周,一个月,三个月,半年,一年时间

    统计时间 label: '统计时间',name: 'countTime',type: 'select',data: [{value: '0',text: '最近一周'},{value: '1',tex ...

  3. JavaScript获取一周前,一个月前日期

    getDay(day) {var today = new Date();var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * ...

  4. oracle获取当前年上一年时间,Oracle获取一周前,一个月前,一年前的日期

    1.获取当前时间一周前的日期 select sysdate - interval '7' day from dual 类似的 当前时间减去7分钟的时间 select sysdate,sysdate - ...

  5. java 1个月前_java获取一个月前的时间

    java获取一个月前的时间 方法一: SimpleDateFormat formatter = new SimpleDateFormat( "yyyyMMdd" ); Date c ...

  6. js 获取某个时间的一天前 几天前 一周前 几周前 一个月前 一年前的时间

    js 获取某个时间的一天前 几天前 一周前 几周前 一个月前 一年前的时间 1.一天前 var dateStr = new Date(); dateStr.setDate(dateStr.getDat ...

  7. Oracle获取一周前,一个月前,一年前的日期,一个月的总天数、一个月的全部日期

    目的:Oracle获取一周前,一个月前,一年前的日期,一个月的总天数.一个月的全部日期 1.获取10分钟前的日期 select sysdate,sysdate-interval '10' minute ...

  8. js 获取当前与一个月前的日期

    在前端页面的日期选择框里放入当前日期以及一个月前的日期.先直接将month减去1,如果减完日期无效,例如:3月31变为2月31,,出现逻辑错误,那就采取减30天的方案 jsp代码 <div cl ...

  9. JavaScript 有关获取当前/上个月/12个月前/七/7天/一周之前/下周一的日期格式 持续更新...

    思路 当前时间获取 主要是利用时间戳的时间差来显示当前时间 在线时间戳转换网站 方便校验https://tool.lu/timestamp/ 时间戳:unix时间戳是从1970年1月1日(UTC/GM ...

最新文章

  1. android 短信验证码的实现
  2. 【驱动】在内核源码中添加驱动程序
  3. property装饰器
  4. day 29 socketsetserver 模块
  5. 剑指offer——变态跳台阶
  6. python去除数组缺失值_动态数组的应用,VBA中如何利用动态数组去除重复值的第二讲...
  7. js的异步请求出现同步效果
  8. Java 集合之自动打包和解包以及泛型
  9. easypoi needmerge失效_EasyPOI简单用例,简单有效
  10. linux程序流量平滑,Linux下按程序查实时流量 network traffic(示例代码)
  11. 字符串中去除连续相同的字符保留一个
  12. c语言控制台不退出程序,怎样可以屏蔽控制台程序的关闭按钮
  13. python 0xa什么意思_python使用xpath中遇到:Element a at 0x39a9a80到底是什么?
  14. Linux 4G/5G 驱动移植、实践测试记录
  15. 绿色软件联盟:杀毒软件已经进入空前弱智与混沌状态
  16. 前端页面局部(全局)刷新方法
  17. Android 音乐播放器的开发教程(六)service的运用及音乐列表点击播放 ----- 小达
  18. 2月15日市场游资操作情况以及龙虎榜
  19. OSI七层模型基础知识及各层常见应用
  20. App三种启动场景:冷启动、热启动、温启动

热门文章

  1. 技术美术知识学习5200:光追相关概念介绍
  2. Possible missing firmware /lib/firmware/rtl_nic/rtl8168fp-3.fw for module r8169
  3. B2B2C 商城系统 WSTMart_v2.0.6_180726程序发布
  4. CSS style属性大全
  5. 扁平化数组的几种方法
  6. Raft 共识算法3-日志复制
  7. 第五人格服务器维护中怎么进游戏,第五人格怎么开始 第五人格怎么进入游戏?[多图]...
  8. allegro16.6使用汇总
  9. [渝粤教育] 天水师范学院 人文地理学 参考 资料
  10. Android Studio 模拟器重启(解决模拟器卡死问题)