Timestamps shifted by several minutes when writing with influxdb-client-swift

Hi, I am experiencing an issue with timestamp accuracy when writing data to InfluxDB using the Swift client (influxdb-client-swift ).

Problem:

When I write data with a fixed date in my Swift app, the entry appears shifted by 4 minutes in the Data Explorer Web Interface. I have created a simple test and can reproduce the issue consistently.

What I have tested:

  • My device’s system time is correctly synchronized
  • The InfluxDB server time is also synchronized (checked via NTP)
  • I use precision: .nanoseconds to avoid rounding errors

Despite these precautions, the entries remain shifted by several minutes. Could there be an automatic adjustment of timestamps by the InfluxDB client or server?

Here is my swift demo code:

var components = DateComponents()
components.year = 2025
components.month = 3
components.day = 4
components.hour = 12
components.minute = 0
components.second = 0
components.nanosecond = 0
components.timeZone = .gmt

let calendar = Calendar.current
let date = calendar.date(from: components)!

let point = InfluxDBClient
    .Point(measurement)
    .addField(key: "temperature", value: .double(3.0))
    .time(time: .date(date))

try await influxDBClient.makeWriteAPI().write(points: [point])

Here is a screenshot from the data explorer

Any help would be greatly appreciated! Thanks in advance. :blush:

I think i figured it out myself. The timeshift is just in the data explorer web view. If I query the data via the commandline I get the correct values.

Hi @patricks,
Thanks so much for sharing your solution with the community I really appreciate it!