I am trying to convert the timestamp 1452454659
to its rfc3339 equivalent.
I am getting the output as:
2016-01-11T01:07:39+05:30
When I pass this to influxdb it returns a time of:
2016-01-10T19:37:39Z
while I actually want the time in influxdb to be:
2016-01-11T01:07:39
I have even tried to pass only 2016-01-11T01:07:39
, leaving out +5:30
, but then it gives me no result.
What mistake am I making?
if your timestamp is from utc format, the following example may help you : (just replace the variable 'd' with your own timestamp)
import datetime
d = datetime.datetime.utcnow()
print d.isoformat("T") + "Z"
--> 2016-01-10T09:33:33.865129Z
I based my answer on the following link : https://docs.python.org/2/library/datetime.html
>>> print datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-4]+"Z"
2016-01-10T10:27:45.89Z
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With