el-date-picker由中国时间转换成格林尼治时间
生活随笔
收集整理的這篇文章主要介紹了
el-date-picker由中国时间转换成格林尼治时间
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在開發(fā)中用到了時(shí)間時(shí)間查詢,查詢之后發(fā)現(xiàn)篩選的不準(zhǔn),經(jīng)過檢查發(fā)現(xiàn)el-date-picker獲取的時(shí)間是中國標(biāo)準(zhǔn)時(shí)間,而后端判斷條件的時(shí)間是格林尼治時(shí)間,會(huì)有8個(gè)時(shí)間的時(shí)差,所以在獲取到時(shí)間之后需要把時(shí)間由中國時(shí)間轉(zhuǎn)換成格林尼治時(shí)間,處理方法如下。
html代碼 <el-date-picker:disabled="noLimit"v-model="startTime"type="datetime"size="small"placeholder="兌換開始時(shí)間"@change="changeStartTime"></el-date-picker> js代碼 methods:{ //轉(zhuǎn)換時(shí)間格式timeChange(date) {var json_date = new Date(date).toJSON();return new Date(+new Date(json_date) + 8 * 3600 * 1000).toISOString().replace(/T/g, " ").replace(/\.[\d]{3}Z/, "");},//開始時(shí)間發(fā)送變化changeStartTime(){this.startTime = this.timeChange(this.startTime)}, }總結(jié)
以上是生活随笔為你收集整理的el-date-picker由中国时间转换成格林尼治时间的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Protocol Buffer编译器安装
- 下一篇: 第六章、面向对象的PHP