# Node-Red -\> Infuxdb - Timestamp out of date

**URL:** <https://discourse.nodered.org/t/node-red-infuxdb-timestamp-out-of-date/77865>\
**Category:** General\
**Created:** [24 April 2023 06:59 UTC](https://discourse.nodered.org/t/node-red-infuxdb-timestamp-out-of-date/77865 "2023-04-24T06:59:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [24 April 2023 06:59 UTC](https://discourse.nodered.org/t/node-red-infuxdb-timestamp-out-of-date/77865/1 "2023-04-24T06:59:48Z")

</div>

I am using Raspberry 4 to run Node-Red, Influxdb and Grafana.

The Pi is set up on Johannasburg South Africa time zone.

The problem if I query the data are a few hours off, I suspect somehow the data are stored with the incorrect time stamp.

Any one have an idea where to look for how this happens?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4f6233546ccecbd63257b4f1f53a36cb3ef6abe7.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/f/dfff0706010d38ec02826e7d280b9a3265819bcc.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/0/40c2b0d6ea9b6a87bc5e2410c2309f3dd1ec6308.png)

Using a test flow in Node-Red

```auto
[
    {
        "id": "1bc44ad459ce827a",
        "type": "debug",
        "z": "639ef7b5796c2a80",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 900,
        "y": 900,
        "wires": []
    },
    {
        "id": "6d62d916ff2d2685",
        "type": "inject",
        "z": "639ef7b5796c2a80",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "10",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 290,
        "y": 940,
        "wires": [
            [
                "22d1b43de61de6d3"
            ]
        ]
    },
    {
        "id": "22d1b43de61de6d3",
        "type": "change",
        "z": "639ef7b5796c2a80",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "Temperature",
                "pt": "global",
                "to": "50*$random()",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "Density",
                "pt": "global",
                "to": "1000*$random()",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "timestamp",
                "pt": "global",
                "to": "",
                "tot": "date"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 480,
        "y": 940,
        "wires": [
            [
                "04c946e6a479bb97"
            ]
        ]
    },
    {
        "id": "04c946e6a479bb97",
        "type": "function",
        "z": "639ef7b5796c2a80",
        "name": "function 2",
        "func": "let dens = global.get('Density')\nlet temp = global.get('Temperature')\nlet timestamp = global.get('timestamp')\n\nmsg.payload = {\n \"Temerature\": temp,\n \"Dencity\": dens\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 700,
        "y": 940,
        "wires": [
            [
                "1bc44ad459ce827a",
                "349f7178fe25791a"
            ]
        ]
    },
    {
        "id": "349f7178fe25791a",
        "type": "influxdb out",
        "z": "639ef7b5796c2a80",
        "influxdb": "01d768772babdcd3",
        "name": "co2",
        "measurement": "sas",
        "precision": "",
        "retentionPolicy": "",
        "database": "database",
        "precisionV18FluxV20": "ns",
        "retentionPolicyV18Flux": "",
        "org": "SOIOT",
        "bucket": "temp",
        "x": 890,
        "y": 940,
        "wires": []
    },
    {
        "id": "01d768772babdcd3",
        "type": "influxdb",
        "hostname": "127.0.0.1",
        "port": "8086",
        "protocol": "http",
        "database": "database",
        "name": "CO2",
        "usetls": false,
        "tls": "",
        "influxdbVersion": "2.0",
        "url": "http://localhost:8086",
        "rejectUnauthorized": false
    }
]

```

---

<div class="post-metadata">

**Author:** ![dougle03](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dougle03/32/32979_2.png) [@dougle03](https://discourse.nodered.org/u/dougle03)\
**Post date:** [24 April 2023 09:19 UTC](https://discourse.nodered.org/t/node-red-infuxdb-timestamp-out-of-date/77865/2 "2023-04-24T09:19:31Z")

</div>

Are you running NR in Docker? If so, the TZ environment variables might be wrong or not set. I've recently discovered that the time zone in a container is not forced to be the same as the host machine without a TZ variable in your docker config..

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [24 April 2023 09:24 UTC](https://discourse.nodered.org/t/node-red-infuxdb-timestamp-out-of-date/77865/3 "2023-04-24T09:24:20Z")

</div>

Have a look [at this topic](https://discourse.nodered.org/t/timestamps-not-being-recorded-correctly/77817/17), looks like the same problem.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 April 2023 10:00 UTC](https://discourse.nodered.org/t/node-red-infuxdb-timestamp-out-of-date/77865/4 "2023-04-24T10:00:12Z")

</div>

I don't think it is the problem in the other thread, that was specifically the influxdb explorer tool that was showing confusing timestamps. This is showing it in grafana.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 April 2023 10:04 UTC](https://discourse.nodered.org/t/node-red-infuxdb-timestamp-out-of-date/77865/5 "2023-04-24T10:04:09Z")

</div>

@ScheepersJohan as well as answering the docker question, what timezone is the machine running the browser set to?

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [24 April 2023 10:57 UTC](https://discourse.nodered.org/t/node-red-infuxdb-timestamp-out-of-date/77865/6 "2023-04-24T10:57:36Z")

</div>

Ok found the problem.

It is the Influxdb node 'node-red-contrib-influxdb' can not be stet to nanosecond for the precision, not that I needed it to that accuracy.

Problem solve by setting to microsecond.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/775f4b7bb7fbccf2b1ab9328fcf071b7d60b7a77.png)

Thank you for everyone's input.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 April 2023 11:37 UTC](https://discourse.nodered.org/t/node-red-infuxdb-timestamp-out-of-date/77865/7 "2023-04-24T11:37:29Z")

</div>

Since you are letting influx add the timestamps that should not make any difference, unless you started with it in nanosecs, recorded some data, and then changed it, which might mess things up I suppose.  
If, starting from scratch, it does make a difference then that is a bug that you should report.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 May 2023 11:37 UTC](https://discourse.nodered.org/t/node-red-infuxdb-timestamp-out-of-date/77865/8 "2023-05-08T11:37:55Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
