Result of $__timeTo() macro works different between 5.0.4 and 5.1.0

While using the PostgreSQL data source, I’ve noticed a different result of the built-in macro $__timeTo(). While it returns in Grafana 5.0.4 the time with my correct time zone it returns on Grafana 5.1.0 a Zulu time. Is this a bug? If this is not a bug, how can I get the macro to return a time in my timezone?

I tried to set the Preferences to use Browser timezone without any effect. The screenshot attached compares the result of the Postgres internal now() vs. the Grafana $__timeTo() macro.

01

Any hints or tips are appreciated.

It’s not a bug, it’s a feature and was fixed in this pull request to make the timeFilter, timeTo and timeFrom more optimal for query performance.

Marcus

Is there a better way as doing something like to_timestamp($__unixEpochTo())?

Not that I’m aware of, but I’m not a postgres expert. Not sure what you’re trying to accomplish, but if you feel some feature is lacking here I would suggest to open a new feature request.

Marcus

You are probably storing local time in a non timezone aware datatype. The proper fix is to use timestamptz or store your times in utc. so the best solution is to change your datatype:

ALTER TABLE metric_table ALTER COLUMN time_column TYPE timestamp with time zone;

timestamp with time zone uses 8 byte the same amount as timestamp without timezone so you dont need more bytes for storage