If your question is: "How do I set the time on a board without network connection?"
The simplest way (nowadays) is using mpremote
.
mpremote
is a MicroPython utility that you can install to your PC, that has a command to set the MCU time to that of your PC.
The requirement is that the MCU is connected via serial (and that nothing else uses that port at the same time).
Install mpremote: pip install -U mpremote
Set MCU time: mpremote rtc --set
( mpremote v1.20+)
Note that MCU time will reset if you reboot it.
PS C:\develop\MyPython\> mpremote rtc --set repl
Connected to MicroPython at COM14
Use Ctrl-] or Ctrl-x to exit this shell
>
MicroPython v1.22.1 on 2024-01-05; ESP32S3 module with ESP32S3
Type "help()" for more information.
>>> import time
>>> time.localtime()
(2024, 1, 15, 1, 13, 11, 0, 15)
Here mpremote
autodetects the first device, connects to that, sets the time, and enters the MicroPython REPL.
More info: https://docs.micropython.org/en/latest/reference/mpremote.html