vue 判斷某個時間小於當前時間


如下

new Date().getTime() 獲取當前時間(毫秒)

我需要對比的時間為秒,所以需要除於1000

<div v-if="scope.row.created_at < new Date().getTime()/1000">
 我小於當前時間,所以會顯示出來
</div>

獲取當前日期時間

data(){
  return{
    updateTime:""
  }
},  
methods:{
//獲取當前年月日
    addDate(){
      const nowDate = new Date();
            const date = {
                year: nowDate.getFullYear(),
                month: nowDate.getMonth() + 1,
                date: nowDate.getDate(),
            }
            const newmonth = date.month>10?date.month:'0'+date.month
            const day = date.date>10?date.date:'0'+date.date
            this.updateTime = date.year + '-' + newmonth + '-' + day
    
    },
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM