Date and time not correct after cold boot

About a week ago one of the home circuits goes down (overload). After this the HA system on mi RPI4 starts up with a wrong date. After a evening trying to correct this the date and time was suddenly correct after a lot of reboots.
After this I have to reinstall the system back to is normal location in the house so it reaches all switches and sensors. The problem repeats. Now it took two cold boots to get it right.
Today the whole street had a power outage. Problems again. Again I had to restart mutiple times. Now I succeed with a warm boot.
Any idea where to find this problem. I can’t correct the time in the terminal mode. Sudo dosn’t work there. It is no HA installed on top of a Linux system, but an image I completely installed.

The only real way to permanently fix this issue is to buy a real-time clock module for the Raspberry Pi, since it’s extremely difficult to reset the time on them.

Thanks for your answer, but what suprises me is that it suddenly appears. The system is running for I think two years now. Never had a problem of this kind.

As part of the start process the operating system contact servers on the internet to get a correct time.
Until the process has completed the time will be whatever the computer have at boot.
If you have a Real Time Clock (RTC) module then it might be a few seconds of, but some computer do not have a RTC module (like Raspberrys) and here the time will be decades off until the process has completed.

I’m familiar with the NTP proces, but that has to take minutes, maybe an hour. In my case it seems to sync at all.

Sometimes there are issues with the nodes on the internet and then it will have to wait for those to be resolved.
Sometimes a too strict firewall prevents access to NTP servers.