I found the module utime on the internet.
if you import utime, you can get the actual time and date with the command utime.localtime()
In the Netherlands it’s now summertime and the time is now correct with the command localtime(), but wil give this command also the right time in the winter?
I couldn’t find anything on the internet for arduino that give the right time summer and winter. Is this an advantage of micropython?
I’m not sure I understood your question.
I think the localtime() should give the correct winter and summer time, but I’m not sure.
As for the Arduino, we have these guides about time:
There are functions to adjust daylight offset as well as time zone in this last tutorial.
I hope this helps.
Sara, i couldn’t get the codes running on a esp8266, but i found on the internet this example, based on your website.
in the file config.h is a rule: const int daylightOffset_sec = 0; // Daylight savings 0|3600
Here you have to change manually the summer and wintertime. That’s not what i want and what MicroPyhton does, that gives automatically the correct time.
I’m sorry. I thought you were using an ESP32. For the ESP8266, we have these guides (similar to the previous ones – not automatic correct date and time, you need to set the parameters or do some calculations):
Thanks Sara, that’s what i needed to know.
So you have to change your sketch twice a year with arduino and you don’t have change it with MicroPython
Oh wow, that is just what i needed.
Many thanks Steve!!!!
I it works is a mystery to me, but who cares.