Advertisement
Guest User

Generation of InfluxDB timestamp in python language

a guest
Apr 9th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import time
  3. import datetime
  4. import math
  5.  
  6. if __name__ == '__main__':
  7.         print "Timestamp en secondes UTC depuis le 01/01/1970 0h00 UTC"
  8.         hs = time.time()
  9.         print hs
  10.         print
  11.  
  12.         print "Verification en convertissant dans un format lisible"
  13.         gm = time.gmtime(hs)
  14.         print gm
  15.         print
  16.  
  17.         print "Pesee du 09/04/2020 (19h 00m 50s)"
  18.         sec = (datetime.datetime(2020, 4, 9, 17,00,50) - datetime.datetime(1970, 1, 1,0,0,0)).total_seconds()
  19.         print sec
  20.         print
  21.  
  22.         print "Timestamp InfluxDB correspondant, en string"
  23.         tsinfluxdb = sec * 1000000000
  24.         Stsinfluxdb = str((math.trunc(tsinfluxdb)))
  25.         print(Stsinfluxdb)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement