I am working with InfluxDB and trying to insert time series data via PowerShell. My goal is to insert data points with specific timestamps containing hours, minutes and seconds into InfluxDB. I am using the InfluxDB API to send the data.

My problem is that even though I am sending the timestamps to InfluxDB correctly (as I believe), the minutes and seconds values always appear as 00 in the database. It looks like only the hours are being picked up correctly, while minutes and seconds are set to zero.

Here is an excerpt from my PowerShell script that prepares the data points and sends them to InfluxDB:

$Uri = "http://...........&precision=s"
$Token = ""
$Headers = @{
    "Authorization" = "Token $Token"
    "Content-Type" = "text/plain"

$DataPoints = @(
@{Id="844161"; Timestamp="24.01.2024 01:15:00"; Value="4,88"; Unit="Wv"},
@{Id="844161"; Timestamp="24.01.2024 01:30:00"; Value="2,4"; Unit="Wv"}


$Data = ""

foreach ($Point in $DataPoints) {
    $DateTimeObject = [datetime]::ParseExact($Point.Timestamp, "dd.MM.yyyy HH:mm:ss", [System.Globalization.CultureInfo]::InvariantCulture)

    $UnixTimestamp = [int64](($DateTimeObject - (Get-Date "1970-01-01T00:00:00Z")).TotalSeconds)

    Write-Host "Timestamp: $($Point.Timestamp), DateTimeObject: $($DateTimeObject.ToString("u")), UnixTimestamp: $UnixTimestamp"

    $Value = ($Point.Value -replace ",", ".")

    $Data += "current,Id=" + $Point.Id + ",Unit=" + $Point.Unit + " Value=" + $Value + " " + $UnixTimestamp + "`n"

$Data = $Data.TrimEnd("`n")
$Response = Invoke-WebRequest -Uri $Uri -Method Post -Headers $Headers -Body $Data -UseBasicParsing

if ($Response.StatusCode -eq 204) {
} else {
    "Errorcode: $($Response.StatusCode)"

The timestamps are given in seconds since 1 January 1970 (Unix time), as specified by the parameter &precision=s in the URI. Nevertheless, the minutes and seconds in the timestamps are not correctly reflected in InfluxDB.

Does anyone have any idea what could be causing the problem or what I should check? Is there something about the way I am converting the timestamps or sending the data that could be causing this problem?

edit: I have printed the timestamps directly into PowerShell to ensure that the minutes and seconds are correctly accounted for, and the output shows the expected values. However, these exact minutes and seconds are not reflected in InfluxDB, where they do not appear as expected.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.