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

推修改时间报错

parent a09bf408
export const timestampToTime = (timestamp, transLength) => { export const timestampToTime = (timestamp, transLength) => {
// 时间戳为10位需*1000,时间戳为13位不需乘1000 // 时间戳为10位需*1000,时间戳为13位不需乘1000
let date = null; let date = null;
if (timestamp) {
if (timestamp.length < 13) { if (timestamp.length < 13) {
date = new Date(timestamp * 1000); date = new Date(timestamp * 1000);
} else { } else {
...@@ -19,13 +20,17 @@ export const timestampToTime = (timestamp, transLength) => { ...@@ -19,13 +20,17 @@ export const timestampToTime = (timestamp, transLength) => {
let m = let m =
(date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
":"; ":";
let s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); let s =
date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
switch (transLength) { switch (transLength) {
case 3: case 3:
return Y + M + D; return Y + M + D;
case 6: case 6:
return Y + M + D + h + m + s; return Y + M + D + h + m + s;
} }
} else {
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