// 时间戳转时间
formatTime = (timestamp) => {
if (timestamp) {
const tempTimestamp = (timestamp.toString().length === 13) ? timestamp : timestamp*1000
const time = new Date(tempTimestamp)
const y = time.getFullYear(); //getFullYear方法以四位数字返回年份
const M = time.getMonth() + 1; // getMonth方法从 Date 对象返回月份 (0 ~ 11),返回结果需要手动加一
const d = time.getDate(); // getDate方法从 Date 对象返回一个月中的某一天 (1 ~ 31)
const h = time.getHours(); // getHours方法返回 Date 对象的小时 (0 ~ 23)
const m = time.getMinutes(); // getMinutes方法返回 Date 对象的分钟 (0 ~ 59)
const s = time.getSeconds(); // getSeconds方法返回 Date 对象的秒数 (0 ~ 59)
// return y + '-' + M + '-' + d;
return y + '-' + M + '-' + d + ' ' + h + ':' + m + ':' + s;
} else {
return '';
}
}
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- nryq.cn 版权所有 赣ICP备2024042798号-6
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务