前端 CST和GMT+0800时间转换(js/vue/react/jsp通用)

2023-04-04 14:56:17 浏览数 (1)

代码语言:javascript复制
             this.beginTime="2031-03-20 00:00:00"
             this.endTime="2031-03-20 00:00:00"

            this.beginTime=new Date(this.beginTime)
            this.endTime=new Date(this.endTime)

            // CST和GMT 0800时间转换
            this.beginTime=this.beginTime.getFullYear() "-" Number(this.beginTime.getMonth()   1) "-" this.beginTime.getDate() " " 
                Number(this.beginTime.getHours()>13?this.beginTime.getHours()-14:this.beginTime.getHours() 10)
             ":" this.beginTime.getMinutes()
            this.endTime=this.endTime.getFullYear() "-" Number(this.endTime.getMonth()   1) "-" this.endTime.getDate() " " 
                Number(this.endTime.getHours()>13?this.endTime.getHours()-14:this.endTime.getHours() 10) ":" this.endTime.getMinutes()

重点:

代码语言:javascript复制
 Number(.getHours()>13?.getHours()-14:.getHours() 10)

0 人点赞