47 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export function timestampToTime(timestamp) {
const date = new Date(timestamp) //时间戳为10位需*1000时间戳为13位的话不需乘1000
const Y = date.getFullYear() + '-'
const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
const D = date.getDate() + ' '
// const h = date.getHours() + ':'
// const m = date.getMinutes() + ':'
// const s = date.getSeconds()
return Y + M + D
}
export function getThisDay(value) {
switch (value) {
case 1:
return '星期一'
case 2:
return '星期二'
case 3:
return '星期三'
case 4:
return '星期四'
case 5:
return '星期五'
case 6:
return '星期六'
case 0:
return '星期日'
}
}
export function getYesterday() {
const date = new Date()
const y = date.getFullYear()
const m = date.getMonth() + 1
const d = date.getDate()
return `${y}-${m}-${d - 1}`
}
//传入时间 拿到昨天的时间
export function handleYesterday(value) {
const date = new Date(value)
const y = date.getFullYear()
const m = date.getMonth() + 1
const d = date.getDate() - 1
return `${y}-${m}-${d}`
}