JS获取当前时间

HTML

{{ times }}

JS

var now = new Date();

var year = now.getFullYear();

var month = now.getMonth() + 1;

var date = now.getDate();

var hour = now.getHours();

var minute = now.getMinutes();

var second = now.getSeconds();

this.times = `${year}-${month}-${date} ${hour}:${minute}:${second}`;

       以上排序可以根据需求更换位置,最终效果以需求为准

你可能感兴趣的:(Vue,Uniapp,javascript,前端,vue.js)