Vue 获取最近一个月,前三个月, 最近半年,最近一年, 当前月末日期
vue
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
项目地址:https://gitcode.com/gh_mirrors/vu/vue
·
/*
* 获取当前年月日
* */
export function nowDate() {
const loadYear = new Date().getFullYear()
let loadMonth = new Date().getMonth() + 1
let loadDay = new Date().getDate()
if (loadMonth >= 1 && loadMonth <= 9) {
loadMonth = '0' + loadMonth
}
if (loadDay >= 0 && loadDay <= 9) {
loadDay = '0' + loadDay
}
const date = loadYear + '-' + loadMonth + '-' + loadDay
return date
}
/*
* 获取前三个月
* */
export function beforeThree() {
const dates = new Date()
dates.setMonth(dates.getMonth() - 3)
var pastMonth = dates.getMonth() + 1
var pastDay = dates.getDate()
if (pastMonth >= 1 && pastMonth <= 9) {
pastMonth = '0' + pastMonth
}
if (pastDay >= 0 && pastDay <= 9) {
pastDay = '0' + pastDay
}
const endDate = dates.getFullYear() + '-' + pastMonth + '-' + pastDay
return endDate
}
/*
* 最近一月
* */
export function oneMonth() {
const dates = new Date()
dates.setMonth(dates.getMonth() - 1)
var pastMonth = dates.getMonth() + 1
var pastDay = dates.getDate()
if (pastMonth >= 1 && pastMonth <= 9) {
pastMonth = '0' + pastMonth
}
if (pastDay >= 0 && pastDay <= 9) {
pastDay = '0' + pastDay
}
const endDate = dates.getFullYear() + '-' + pastMonth + '-' + pastDay
return 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() + 1
var pastDay = pastDate.getDate()
if (pastMonth >= 1 && pastMonth <= 9) {
pastMonth = '0' + pastMonth
}
if (pastDay >= 0 && pastDay <= 9) {
pastDay = '0' + pastDay
}
var endDate = pastYear + '-' + pastMonth + '-' + pastDay
return 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() + 1
var 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 + strDate
return 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) + '-' + endDay
return 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
}
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:3 个月前 )
9e887079
[skip ci] 1 年前
73486cb5
* chore: fix link broken
Signed-off-by: snoppy <michaleli@foxmail.com>
* Update packages/template-compiler/README.md [skip ci]
---------
Signed-off-by: snoppy <michaleli@foxmail.com>
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 1 年前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)