18 lines
278 B
JavaScript
18 lines
278 B
JavaScript
/**
|
|
* date转化为hh:mm
|
|
*/
|
|
export function dateToStr(date) {
|
|
if (typeof date !== 'number') {
|
|
return ''
|
|
}
|
|
date = new Date(date)
|
|
let hh = date.getHours()
|
|
let mm = date.getMinutes()
|
|
if (hh<10) {
|
|
hh = '0' + hh
|
|
}
|
|
if (mm<10) {
|
|
mm = '0' + mm
|
|
}
|
|
return hh + ':' + mm
|
|
} |