Vue 获取当前时间(年月日 时分秒)
【代码】Vue 获取当前时间(年月日 时分秒)
·
一、代码实现
// 获取当前时间
const getGurrentTime = () => {
let yy = new Date().getFullYear();
let mm = (new Date().getMonth() + 1) < 10 ? '0' + (new Date().getMonth() + 1) : (new Date().getMonth() + 1);
let dd = (new Date().getDate()) < 10 ? '0' + (new Date().getDate() + 1) : (new Date().getDate() + 1);
let hh = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours();
let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
return yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss;
};
二、实现效果
更多推荐
所有评论(0)