Data showing incorrect timezone in Explorer

Hi,

I’m pushing data into InfluxDB using the API /write endpoint. My script is reading timestamps from some Zigbee temperature sensors via a Hubitat hub. The timestamp data is presented as a yyyy-MM-ddThh:mm:ssz string, for instance:
“2021-01-24T01:19:43+0000”

This value is then being parsed by the script and converted into UNIX Epoch time:
PowerShell:
$timestamp = [System.DateTimeOffset]::Parse($date).ToUnixTimeSeconds
Python:
timestamp = datetime.datetime.strptime(date, "%Y-%m-%dT%H:%M:%S%z").strftime("%s")

When run against the sample timestamp included above, both the PowerShell and Python methods return 1611451183. However, when looking at the data in Explorer in raw view, all the timestamps are shown with a -10 hour offset; in this example: 2021-01-23T15:19:34.000Z

The ten hour offset is not random: I’m in Brisbane, Australia, which is UTC+10. Influx appears to be treating the time sent through as local time, and then removing the UTC offset again.

What am I doing wrong?

Hello @Sanx ,
I’m not sure have you looked at this configuration option?
https://docs.influxdata.com/influxdb/cloud/visualize-data/dashboards/control-dashboard/#select-timezone

Hi @Anaisdg
I eventually tracked down the problem to (surprise surprise) a bug in my code. Turns out the Python .strftime("%s") function is not timezone aware. It was therefore treating the UTC time it was being passed as local time (for me - UTC+10) when calculating Epoch time.

No bugs in Influx; just this idiot not being able to read documentation properly.

Thanks

Dan.

1 Like

Hey @Sanx,
Happy it’s solved. Lol now don’t go stealing one of my signature moves :stuck_out_tongue: