<div class="right">{
{
time}}</div>
export default {
data() {
return {
time:'',
}
},
mounted(){
this.init()
},
methods:{
init(){
Date() {
let that = this
that.timer = setInterval(function() {
const nowDate = new Date();
const date = {
year: nowDate.getFullYear(),
month: nowDate.getMonth() + 1,
date: nowDate.getDate(),
hours: nowDate.getHours(),
minutes: nowDate.getMinutes(),
seconds: nowDate.getSeconds(),
};
const ampm = date.hours < 12 ? 'am' : 'pm';
const newhours = date.hours > 9 ? date.hours : "0" + date.hours
const newminutes = date.minutes > 9 ? date.minutes : "0" + date.minutes
const newsecond = date.seconds > 9 ? date.seconds : "0" + date.seconds
const newmonth = date.month > 9 ? date.month : "0" + date.month;
const newday = date.date > 9 ? date.date : "0" + date.date;
const year = date.year;
that.time = newhours + ":" + newminutes + ":" + newsecond + " " + newday + "/" + newmonth +
"/" + year;
}, 1000)
},