devicesmgt/sgzb-screen/src/untils/time.js

17 lines
410 B
JavaScript
Raw Normal View History

2023-12-16 18:10:04 +08:00
function p(s) {
return s < 10 ? '0' + s : s
}
// 时间格式
export function DateConversion(time) {
const d = new Date(time)
const resDate =
d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate())
return resDate
}
// 时间戳生成随机ID
export const randomId = (randomLength = 10) => {
return Number(Math.random().toString().substr(3, randomLength) + Date.now()).toString(36)
}