xieb
2023-09-18 2900f50c28b5e2a1cb0f72e4556fb761f61c408e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import {
  DATE_FORMAT,
  DEFAULT_PLACEHOLDER
} from '/@/utils/constants'
import moment, { Moment } from 'moment'
 
// 时间字符串 或者 Unix 时间戳(毫秒数)
export function formatDateTime (time: string | number, format = DATE_FORMAT) {
  return time ? moment(time, format) : DEFAULT_PLACEHOLDER
}
 
// Unix 时间戳 (秒)
export function formatUnixTime (time: number, format = DATE_FORMAT): string {
  return time ? moment.unix(time).format(format) : DEFAULT_PLACEHOLDER
}