${vm.utcTimeToTimezoneStr(vm.$unixTimeParseToString(vm.toMillisecondTime(parseInt(params[0].axisValue)) / 1000, 'yyyy-MM-dd hh:mm:ss'), 'hh:mm')}
${vm.utcTimeToTimezoneStr(vm.toMillisecondTime(parseInt(params[0].axisValue), 'yyyy-MM-dd hh:mm:ss'))}
`
params.forEach(item => {
diff --git a/nezha-fronted/src/main.js b/nezha-fronted/src/main.js
index 3d5f35677..eb213b441 100644
--- a/nezha-fronted/src/main.js
+++ b/nezha-fronted/src/main.js
@@ -18,6 +18,8 @@ import { hasPermission, hasButton } from './permission'
import plTable from 'pl-table'
import 'pl-table/themes/index.css'
+import moment from 'moment-timezone'
+
import { post, get, put, del } from './http.js'
import { clickoutside, bottomBoxWindow, stringTimeParseToUnix, unixTimeParseToString, chartResizeTool, tableSet, cancelWithChange, myLoading } from './components/common/js/tools.js'
import * as tools from './components/common/js/tools.js'
@@ -104,13 +106,17 @@ Vue.mixin({
return bus.UTCTimeToConfigTimezone(time)
}
},
- utcTimeToTimezoneStr: function (time) {
+ utcTimeToTimezoneStr: function (time, fmt) {
+ if (!fmt) {
+ fmt = localStorage.getItem('nz-default-dateFormat') || 'YYYY-MM-DD HH:mm:ss'
+ }
if (time) {
- return bus.timeFormate(bus.UTCTimeToConfigTimezone(time), localStorage.getItem('nz-default-dateFormat') || 'YYYY-MM-DD HH:mm:ss')
+ return bus.timeFormate(bus.UTCTimeToConfigTimezone(time), fmt)
} else {
return '-'
}
},
+
timezoneToUtcTime: function (time) {
if (time) {
return bus.configTimezoneToUTCTime(time)
@@ -189,6 +195,17 @@ Vue.mixin({
return str
}
},
+ momentTz (timestamp, fmt) { // moment 转化时间戳为str
+ const offset = localStorage.getItem('nz-sys-timezone')
+ const format = fmt || localStorage.getItem('nz-default-dateFormat')
+ return moment.tz(timestamp, offset).format(format)
+ },
+ momentStrToTimestamp (str, fmt) {
+ const offset = localStorage.getItem('nz-sys-timezone')
+ const format = fmt || localStorage.getItem('nz-default-dateFormat')
+ const date = moment.tz(str, format, offset).valueOf()
+ return date
+ },
copyRow (row, rightBoxValKey, idKey = 'id', show = false, format, callback) {
/*
row 表格当前行