Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Formatting time for influxdb

I want to input a date/time into influx db from python but not sure how to do this. Python code datetime.datetime.now() currently gives out a format like this : 2018-06-25 13:59:36.698000.

I know this format is accepted by influx "1529932431998" which is "2018-06-25T13:13:51.998Z" or "0x1643714427e". Any ideas how i can get python to give me 11 digit number from python?

Thanks

like image 679
resolver101 Avatar asked Oct 17 '25 18:10

resolver101


1 Answers

Looks like you need epoch time.

Try:

import datetime
import time
print( time.mktime(datetime.datetime.now().timetuple()) )

Output:

1529932959.0
like image 122
Rakesh Avatar answered Oct 19 '25 10:10

Rakesh