vue gets new Date().getTime() timestamp
I found a problem when handling button display:
vue The time stamp is obtained by getting the timestamp by new Date().getTime() and returns a 13-digit number, in milliseconds;
The timestamp obtained by php background time() is 10 digits, in seconds;
Therefore, when judging comparison, you need to convert time()*1000 to milliseconds before comparing
<el-button v-if="new Date(.end_time*1000).getTime()>new Date().getTime()" size="mini" icon="edit" @click="editGroupsAction(scope.$index, )">edit</el-button>
vue dynamically gets the current time
Get the current time:
<template> <div > <span class="deadline">Deadline{{ gettime }}</span> </div> </template> <script> export default { name: "Home", data() { return { gettime: "", //Current time }; }, methods: { getTime() { var _this = this; let yy = new Date().getFullYear(); var mm = new Date().getMonth() > 9 ? new Date().getMonth() + 1 : new Date().getMonth() == 9 ? new Date().getMonth() + 1 : '0' + (new Date().getMonth() + 1); var dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate(); let hh = 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(); _this.gettime = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss; }, currentTime() { setInterval(, 1000); }, }, mounted() { (); }, }; </script> <style scoped> </style>
Get the current date:
<template> <div > <span class="deadline">Current date{{ sendTime }}</span> </div> </template> <script> export default { name: "Home", data() { return { sendTime: "", //Current time }; }, mounted() { (); }, methods: { format() { const nowDate = new Date(); const date = { year: (), month: () + 1, date: (), } const newmonth = > 9 ? : '0' + const day = > 9 ? : '0' + = + '.' + newmonth + '.' + day }, //Get the current time }, }; </script> <style scoped> </style>
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.