vue时间处理年月日时分秒
export default {data() {return {//年月日时分秒getDateStr5(seconds) {var date = new Date(seconds)var year = date.getFullYear();var month = date.getMonth(...
export default {
data() {
return {
//年月日时分秒
getDateStr5(seconds) {
var date = new Date(seconds)
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
var currentTime = year + "-" + month + "-" + day +" "+ hour + ":" + minute + ":" + second;
return currentTime
},
//秒转化为时分秒
formatSeconds(value) {
let result = parseInt(value)
let h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600)
let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60))
let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60))
result = `${h}:${m}:${s}`
return result
},
};
},
};
更多推荐
所有评论(0)