//將當前時間,轉換為年月日形式,調取this.timeStamp()
點擊查看代碼
timeStamp: function(value) {
var date = new Date(value*1000); //時間戳為10位需*1000,時間戳為13位的話不需乘1000
var year = date.getFullYear();
var month = ("0" + (date.getMonth() + 1)).slice(-2);
var sdate = ("0" + date.getDate()).slice(-2);
var hour = ("0" + date.getHours()).slice(-2);
var minute = ("0" + date.getMinutes()).slice(-2);
var second = ("0" + date.getSeconds()).slice(-2);
// 拼接
var result = year + "年" + month + "月" + sdate + "日 " + hour + "時" + minute + "分" + second + "秒";
// 返回
return result;
},
//系統時間格式轉換成自定義格式
點擊查看代碼
getDate(type) {
// 獲取當前系統時間
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
month = month > 9 ? month : '0' + month;;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
