源文件
This commit is contained in:
13
jeepay-ui-uapp-agent/util/timeInterval.js
Normal file
13
jeepay-ui-uapp-agent/util/timeInterval.js
Normal file
@@ -0,0 +1,13 @@
|
||||
export function getDay(num, str) {
|
||||
//如果要获取昨天的日期,num就是-1, 前天的就是-2,依次类推。str表示年月日间的分割方式。
|
||||
const today = new Date()
|
||||
const nowTime = today.getTime()
|
||||
const ms = 24 * 3600 * 1000 * num
|
||||
today.setTime(nowTime + ms)
|
||||
const oYear = today.getFullYear()
|
||||
let oMoth = (today.getMonth() + 1).toString()
|
||||
if (oMoth.length <= 1) oMoth = "0" + oMoth
|
||||
let oDay = today.getDate().toString()
|
||||
if (oDay.length <= 1) oDay = "0" + oDay
|
||||
return oYear + str + oMoth + str + oDay
|
||||
}
|
||||
Reference in New Issue
Block a user