Vue.prototype.showTime = function (d) {
let year;
let month;
let date;
let hour;
let minute;
let second;
let nowtime;
if(d){
nowtime = new Date(d);
}else {
nowtime = new Date();//没有传入date 就按现在的时间
}
year = nowtime.getFullYear();
month = nowtime.getMonth() + 1;
date = nowtime.getDate();
hour = nowtime.getHours();
if (hour < 10) {
hour = "0" + hour;
}
minute = nowtime.getMinutes();
if (minute < 10) {
minute = "0" + minute;
}
second = nowtime.getSeconds();
if (second < 10) {
second = "0" + second;
}
let nowTime = year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
return nowTime;
};
1.如需转载本站原创文章,请务必注明文章出处并附上链接,非常感谢。
2.本站用于记录个人 工作、学习、生活,非商业网站,更多信息请 点击这里