CongducPham / LowCostLoRaGw

Low-cost LoRa IoT & gateway with SX12XX (SX1261/62/68; SX1272/76/77/78/79; SX1280/81), RaspberryPI and Arduino boards
703 stars 354 forks source link

MongoDB on Zulu (GMT+0) Time #305

Open man4567890 opened 3 years ago

man4567890 commented 3 years ago

Hi Although my time zone is set to GMT +2, the MongoDB saves the values in Zulu time or GMT

pi@iot-gateway01:~/lora_gateway/sensors_in_raspi $ date
Wed 24 Mar 09:01:21 SAST 2021
pi@iot-gateway01:~/lora_gateway/sensors_in_raspi $ 

image

Anyway to fix that please?

CongducPham commented 3 years ago

You need to change how time is handle in the python script that saves data in Mongo: CloudMongoDB.py, line 66

man4567890 commented 3 years ago

The change that seems to work is in Mongo: CloudMongoDB.py, line 66

now = datetime.datetime.utcnow()

now = datetime.datetime.now()

image

pi@iot-gateway01:~/lora_gateway $ date
Wed 24 Mar 12:08:29 SAST 2021
pi@iot-gateway01:~/lora_gateway $ 

Thanks for the help!