diff --git a/packages/grafana-data/src/datetime/moment_wrapper.ts b/packages/grafana-data/src/datetime/moment_wrapper.ts
index 73f5850dde5..a89d56279c3 100644
--- a/packages/grafana-data/src/datetime/moment_wrapper.ts
+++ b/packages/grafana-data/src/datetime/moment_wrapper.ts
@@ -130,6 +130,12 @@ export const dateTimeForTimeZone = (
return toUtc(input, formatInput);
}
+ if (timezone && timezone !== 'browser') {
+ // TODO fix types here
+ //@ts-ignore
+ return moment.tz(dateTimeAsMoment(input), formatInput, timezone);
+ }
+
return dateTime(input, formatInput);
};
diff --git a/public/app/core/components/TimePicker/TimePickerWithHistory.test.tsx b/public/app/core/components/TimePicker/TimePickerWithHistory.test.tsx
index c946efe0547..87ab11d13c8 100644
--- a/public/app/core/components/TimePicker/TimePickerWithHistory.test.tsx
+++ b/public/app/core/components/TimePicker/TimePickerWithHistory.test.tsx
@@ -129,7 +129,7 @@ describe('TimePickerWithHistory', () => {
it('Should display handle timezones correctly', async () => {
const timeRange = getDefaultTimeRange();
- render();
+ render();
await userEvent.click(screen.getByLabelText(/Time range selected/));
await clearAndType(getFromField(), '2022-12-10 00:00:00');
diff --git a/public/app/features/dashboard/utils/panel.ts b/public/app/features/dashboard/utils/panel.ts
index 38156c1c115..cd178de9a4d 100644
--- a/public/app/features/dashboard/utils/panel.ts
+++ b/public/app/features/dashboard/utils/panel.ts
@@ -1,6 +1,6 @@
import { isString as _isString } from 'lodash';
-import { TimeRange, AppEvents, rangeUtil, dateMath, PanelModel as IPanelModel } from '@grafana/data';
+import { TimeRange, AppEvents, rangeUtil, dateMath, PanelModel as IPanelModel, dateTimeAsMoment } from '@grafana/data';
import { getTemplateSrv } from '@grafana/runtime';
import appEvents from 'app/core/app_events';
import config from 'app/core/config';
@@ -126,11 +126,13 @@ export function applyPanelTimeOverrides(panel: PanelModel, timeRange: TimeRange)
}
if (_isString(timeRange.raw.from)) {
- const timeFromDate = dateMath.parse(timeFromInfo.from)!;
+ const fromTimezone = dateTimeAsMoment(timeRange.from).tz();
+ const toTimezone = dateTimeAsMoment(timeRange.to).tz();
+ const timeFromDate = dateMath.parse(timeFromInfo.from, undefined, fromTimezone)!;
newTimeData.timeInfo = timeFromInfo.display;
newTimeData.timeRange = {
from: timeFromDate,
- to: dateMath.parse(timeFromInfo.to)!,
+ to: dateMath.parse(timeFromInfo.to, undefined, toTimezone)!,
raw: {
from: timeFromInfo.from,
to: timeFromInfo.to,