Files
frontend-app/utils/func.js
T
2025-08-13 00:05:08 +08:00

44 lines
685 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export default {
formatDate (date,val) {
let y = date.getFullYear();
let m = date.getMonth()+1;
let d = date.getDate();
let h = date.getHours();
let mm = date.getMinutes();
let s = date.getSeconds();
if(m <= 9){
m = '0' + m;
}
if(d <= 9){
d = '0' + d;
}
if(h <= 9){
h = '0' + h;
}
if(mm <= 9){
mm = '0' + mm;
}
if(s <= 9){
s = '0' + s;
}
let tmpTime = '';
if(val == 0){
tmpTime = `${h}:${mm}`;
}else if(val == 1){
tmpTime = `${m}-${d}`;
}else if(val == 2){
tmpTime = `${y}-${m}-${d} ${h}:${mm}:${s}`;
}else if(val == 3){
tmpTime = `${y}-${m}-${d}`;
}
return tmpTime;
}, 
}