timestampToTime (timestamp, format = 'yyyy-MM-dd HH:mm:ss') {
// timestamp 时间
/*
* format 格式化
* yyyy 年
* M 月 不补0
* MM 月
* d 日 不补0
* dd 日
* H 时 不补0
* HH 时
* m 分 不补0
* mm 分
* s 秒 不补0
* ss 秒
*
* */
function add0 (m) { return m < 10 ? '0' + m : m; }
let time = new Date(timestamp);
let y = time.getFullYear();
let m = time.getMonth() + 1;
let d = time.getDate();
let h = time.getHours();
let mm = time.getMinutes();
let s = time.getSeconds();
return timestamp ? format.replace(/yyyy/g, y).replace(/MM/g, add0(m)).replace(/M/g, m).replace(/dd/g, add0(d)).replace(/d/g, d).replace(/HH/g, add0(h)).replace(/H/g, h).replace(/mm/g, add0(mm)).replace(/m/g, mm).replace(/ss/g, add0(s)).replace(/s/g, s) : '';
}
@Author: luch
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。