You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
634 B
22 lines
634 B
///格式化显示时间
|
|
let formatTime = function(time,format = 'YY.MM.DD hh:mm'){
|
|
let date = new Date(time * 1000);
|
|
let year = date.getFullYear();
|
|
let mouth = date.getMonth() + 1;
|
|
let day = date.getDay();
|
|
let hour = date.getHours();
|
|
let min = date.getMinutes();
|
|
//sec = date.getSeconds(),
|
|
let preArr = Array.apply(null,Array(10)).map(function(elem,index){
|
|
return '0' + index;
|
|
});
|
|
let newTime = format.replace(/YY/g,year).replace(/MM/g,preArr[mouth] || mouth)
|
|
.replace(/DD/g,preArr[day] || day)
|
|
.replace(/hh/g,preArr[hour] || hour)
|
|
.replace(/mm/g,preArr[min] || min);
|
|
return newTime;
|
|
}
|
|
|
|
export default{
|
|
formatTime,
|
|
}
|