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