# Python script is is storing data an hour in the future

**URL:** <https://community.influxdata.com/t/python-script-is-is-storing-data-an-hour-in-the-future/6923>\
**Category:** Systems\
**Tags:** influxdb\
**Created:** [October 6, 2018, 5:09pm UTC](https://community.influxdata.com/t/python-script-is-is-storing-data-an-hour-in-the-future/6923 "2018-10-06T17:09:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelster101757](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kelster101757](https://community.influxdata.com/u/kelster101757)\
**Post date:** [October 6, 2018, 5:09pm UTC](https://community.influxdata.com/t/python-script-is-is-storing-data-an-hour-in-the-future/6923/1 "2018-10-06T17:09:41Z")

</div>

When I run the follow command it inserts it into the database an hour in the future even though the time from the python prompt “str(datetime.datetime.now())” says the correct time. The python script is run on a Raspberry PI and I’m viewing the data through Grafana via a web browser from a Windows PC. Grafana is installed on the pi.

This is the code im writing:

data = [{“measurement”: “AirParticles”,  
“tags”: {  
“Location”:“living\_room”,  
“Floor”: “1st\_Floor”  
},  
“time”: str(datetime.datetime.now()),  
“fields”: {  
“03um” : gr03um\_average  
}

```
        }
]

```

client.write\_points(data)

---

<div class="post-metadata">

**Author:** ![mhfrantz](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mhfrantz/32/2024_2.png) [@mhfrantz](https://community.influxdata.com/u/mhfrantz)\
**Post date:** [October 6, 2018, 8:32pm UTC](https://community.influxdata.com/t/python-script-is-is-storing-data-an-hour-in-the-future/6923/2 "2018-10-06T20:32:52Z")

</div>

Is it a time zone problem?

---

<div class="post-metadata">

**Author:** ![kelster101757](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kelster101757](https://community.influxdata.com/u/kelster101757)\
**Post date:** [October 7, 2018, 4:02pm UTC](https://community.influxdata.com/t/python-script-is-is-storing-data-an-hour-in-the-future/6923/3 "2018-10-07T16:02:56Z")

</div>

Maybe. But I cant figure out where the problem is coming from? any ideas on to figure this out.

---

<div class="post-metadata">

**Author:** ![kelster101757](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kelster101757](https://community.influxdata.com/u/kelster101757)\
**Post date:** [October 7, 2018, 4:16pm UTC](https://community.influxdata.com/t/python-script-is-is-storing-data-an-hour-in-the-future/6923/4 "2018-10-07T16:16:06Z")

</div>

i type into influxdb “SHOW DIAGNOSTICS” and this is what it showed

| PID | currentTime | started | uptime |
| --- | --- | --- | --- |
| 465 | “2018-10-07T16:09:38.381746869Z” | “2018-10-06T16:52:37.696629892Z” | “23h17m0.685119425s” |

which is the an hour different to the linux command “date”

Sun 7 Oct 17:09:38 BST 2018. ones showing BST and the other is UTC i guess? how does influx interpret this date?

Thanks

---

<div class="post-metadata">

**Author:** ![kelster101757](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kelster101757](https://community.influxdata.com/u/kelster101757)\
**Post date:** [October 7, 2018, 8:24pm UTC](https://community.influxdata.com/t/python-script-is-is-storing-data-an-hour-in-the-future/6923/5 "2018-10-07T20:24:37Z")

</div>

solved it, just replaced the line “time”: str(datetime.datetime.now())" with ““time”: str(datetime.datetime.utcnow())”

The key inforamtion i was missing was influx requires the time in utc which makes sense.
