Page 1 of 1

date time system

Posted: Thu Jul 11, 2019 7:53 pm
by nebenzahl
Hello!
I'm in the development phase of a project so I print the date time each time I reboot my device with the print command (time.localtime ()). And sometimes comes the result (2000, 1, 1, 0, 0, 4, 5, 1) which is the starting time date. But sometimes I get the correct correct date time. However I did not do anything to set this system time. Where does my ESP32 get this time? Is it safe to use it?

Re: date time system

Posted: Fri Jul 12, 2019 8:27 am
by pythoncoder
What IDE or development environment are you using? Perhaps that is setting the time. Note that the RTC will continue to run through a reboot.

The simple way to set the time is to acquire internet connectivity and run ntptime which gets time from an NTP server:

Code: Select all

import ntptime
ntptime.settime()

Re: date time system

Posted: Fri Jul 12, 2019 11:48 am
by nebenzahl
Yes, I understand that.
I use vscode.
I was curious because I do not use any way to update the time, however, suddenly the time is correct.
I can not imagine what makes the time right.
In this project I use the time directly from the satellite. and in the device the time is not important.

Re: date time system

Posted: Fri Jul 12, 2019 2:48 pm
by dhylands
If you happen to be using rshell, it sets the time of the board to match the time of the PC.

Re: date time system

Posted: Sat Jul 13, 2019 1:26 pm
by nebenzahl
Yes, that's it, I use rshell.
Great deduction.
Thanks for listening.
Really Thank you so much!