Chapter 2 - Hard Time

When timekeeping is critical to a project, eg: for scheduled control, then relying on ESP time may not be enough.
I have experienced many thunder-storms which have caused power outages and device reboots.
If coupled with loss of internet connection (as is often the case) it will cause the ESP to start up on "groundhog day"  (1/1/1970)

Or maybe you just prefer to stay isolated from external internet access, or perhaps need to be mobile in a vehicle without an internet connection.

An effective way to keep accurate time during power outages and without internet access to time servers, is to use a hardware Real Time Clock.

Battery-backup RTC modules are available for less than a quid and can keep accurate time even when your ESP loses power. The ESP can read the correct RTC time again after it restarts. They use i2c, therefore you are able to use the same 2 pins for additional i2c modules if you wish.
(there is even a Wemos D1 Mini RTC plug-in shield available - it doesn't get much easier than that).

A small button-cell battery should last for many power-outages, but rechargeable button-cells are available which might last indefinitely.