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?