getNowDate()
{
var timestamp
= Date
.parse(new Date());
var date
= new Date(timestamp
);
var Y =date
.getFullYear();
var M = (date
.getMonth() + 1 < 10 ? '0' + (date
.getMonth() + 1) : date
.getMonth() + 1);
var D = date
.getDate() < 10 ? '0' + date
.getDate() : date
.getDate();
console
.log("当前时间:" + Y + '年' + M+ '月' + D+ '日' );
}
onShow()
{
this.getNowDate()
}
console.log(“当前时间:” + Y + ‘年’ + M+ ‘月’ + D+ ‘日’ ); 结果:当前时间:2020年10月22日
转载请注明原文地址: https://lol.8miu.com/read-29101.html