add seconds of today
This commit is contained in:
parent
3e66326583
commit
13f95077d3
@ -11,11 +11,15 @@ import datetime
|
||||
|
||||
def on_message(client, userdata, msg):
|
||||
j = json.loads(msg.payload)
|
||||
now = datetime.datetime.now()
|
||||
midnight = now.replace(now.year, now.month, now.day, 0,0,0,0)
|
||||
seconds = (now - midnight).seconds
|
||||
j['metadata']['timestamp'] = datetime.datetime.now()
|
||||
j['metadata']['seconds'] = seconds
|
||||
print(j)
|
||||
mongoClient = pymongo.MongoClient('localhost')
|
||||
db = mongoClient.iot
|
||||
r = db.iot.insert(j)
|
||||
r = db.iot.insert_one(j)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
x
Reference in New Issue
Block a user