新建js文件:

/**
* 获取当前时区
*/

export const offset = function() {
var nowTime = new Date()
var offset1 = nowTime.getTimezoneOffset() / 60
return -offset1
}

组件中使用:

<script>
import {offset} from '../../assets/js/offset.js'
export default {
name: 'App',
mounted(){
console.log('获取当前时区',offset())
console.log('转后时间',this.$moment("2019-11-06T06:55:31.161153Z").utcOffset(8).format('YYYY-MM-DD HH:mm:ss'))
}
}
</script>