Hi,
for me it seems th most important issue is to detect the turn off of the MCU. This might be realized by observing the supply voltage by an ADC or a supervisor IC [1] which is triggering an interrupt. This approach requires enough energy stored on the PCB (capacitors) to enable the storage of the current timer value, before the MCU is completely powered down. The ADC/supervisor has to observe an "isolated-version" of the power supply e.g. by means of a diode, otherwise you are measuring the buffered voltage (energy) stored in the capacitors.
If you are interested in the actual time, use an RTC IC. Have a look at the PT7C43390 [2] which provides the followong ability "Users always can take back the information in the registers which is stored before power-off the main power supply, after the voltage is restored."
[1]
https://www.ti.com/power-management/supervisor-reset-ic/products.html
[2]
https://www.diodes.com/assets/Datasheets/PT7C43390.pdf
BR