前端計算當天 本週 本月 本季 今年的起止日期

2021-10-25 11:48:50 字數 1419 閱讀 1813

1.完整**

今天本週

本月本季

今年

2.執行結果

3.通過 eslint校驗的vue版**

// 日期格式化

// eslint-disable-next-line

date.prototype.format = function(format)

if (/(y+)/.test(format))

for (var k in o) )`).test(format))

} return format

}export default function choosedate(val)

if (mmyweekday < 10)

return myyear + '-' + mymonth + '-' + mmyweekday

} // 計算本月多少天

function getmonthdays(mymonth)

// 獲取本季度的開始月份

function getquarterstartmonth()

return quarterstartmonth

} switch (val)

break

}case 2:

// 本週

break

}case 3:

// 本月

var monthstart = new date(nowyear, nowmonth, 1)

var start = formatdate(monthstart)

var monthend = new date(

nowyear,

nowmonth,

getmonthdays(nowmonth)

)var end = formatdate(monthend)

params =

break

case 4:

break

}case 5:

break

}default:

break

} return params

}

呼叫

import choosedate from '@/common/choosedate'
const dates = choosedate(val) // val取值1 2 3 4 5
~~~~~~~~~~~~~~~~~777777777777~~~~~~~~~~~~~~~~~~~~~

MySql查詢當天 本週 本月 本季度 本年的資料

select from 表名 where to days 時間欄位名 to days now select from 表名 where to days now to days 時間欄位名 1 select from 表名 where yearweek date format 時間欄位名,y m d ...

MySql查詢當天 本週 本月 本季度 本年的資料

一 建立測試資料 二 sql查詢及示例 1.今天 select from 表名 where to days 時間欄位名 to days now select from demo s where to days s.create time to days now 2.昨天 select from 表名...

mysql 查詢當天 本週 本月 的記錄

今天 select from 表名 where to days 時間欄位名 to days now 昨天 select from 表名 where to days now to days 時間欄位名 1近7天 select from 表名 where date sub curdate interva...