Convert Time Epoch in Date ,OpenWeather
Posted: Wed Jun 29, 2022 5:56 pm
Hello
Always big problem
I use ESP32 with THONNY ( Micropython)
I have make this program witch work well , the connection to wifi is not represented
The date is in "Time Epoch" format .....and when i try to convert this date i have an erroneous date in 2052....
Is there anybody witch can explain me how to convert this EPOCH date in conventional date
Thanks very much
best regards
Always big problem
I use ESP32 with THONNY ( Micropython)
I have make this program witch work well , the connection to wifi is not represented
Code: Select all
[color=#008000]import urequests
APIKEY = "fb07531d1fe37a3effcdf3755be2f6a9" #OpenWeather
API_call = "http://api.openweathermap.org/data/2.5/forecast?id=524901&lang=fr&appid="+APIKEY
reponse = urequests.get(API_call)
res = reponse.json()
print(res)
print(res.keys())
print(res['list'][0])
print('vent',res['list'][0]['wind']['speed'],'m/s')
print('direction',res['list'][0]['wind']['deg'],'degre')
print('date',res['list'][0]['dt_txt'])
print('')
print('niveau sol',res['list'][0]['main']['grnd_level'],'hPa')
print('temp mini',(res['list'][0]['main']['temp_min'])-273.15)
print('temp max',(res['list'][0]['main']['temp_max'])-273.15)
print('humidite',res['list'][0]['main']['humidity'],'%')
print('visibilite',res['list'][0]['visibility'],'m')
print('date',res['list'][0]['dt'])[/color]
Is there anybody witch can explain me how to convert this EPOCH date in conventional date
Thanks very much
best regards