Commit fc5d0229 authored by 姬鋆屾's avatar 姬鋆屾

推修改时间报错

parent a09bf408
export const timestampToTime = (timestamp, transLength) => {
// 时间戳为10位需*1000,时间戳为13位不需乘1000
let date = null;
if (timestamp.length < 13) {
date = new Date(timestamp * 1000);
if (timestamp) {
if (timestamp.length < 13) {
date = new Date(timestamp * 1000);
} else {
date = new Date(timestamp);
}
let Y = date.getFullYear() + "-";
let M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
let D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
let h =
" " +
(date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) +
":";
let m =
(date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
":";
let s =
date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
switch (transLength) {
case 3:
return Y + M + D;
case 6:
return Y + M + D + h + m + s;
}
} else {
date = new Date(timestamp);
}
let Y = date.getFullYear() + "-";
let M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
let D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
let h =
" " +
(date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) +
":";
let m =
(date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
":";
let s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
switch (transLength) {
case 3:
return Y + M + D;
case 6:
return Y + M + D + h + m + s;
return "";
}
};
// 小时:分钟 ==》 转分钟
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment