Game on real time

It is necessary to write the dependence of the application from real time. When closing the application, the timer should not stop.

For example: every 10 minutes the background should change or the hunger value should decrease every minute (the timer does not stop when the application is turned off)

I am a beginner and do not know how to create this function.

Нужно написать зависимость приложения от реального времени. При закрытии приложения таймер не должен останавливаться.

Например: каждые 10 минут должен меняться фон или значение голода должно уменьшаться каждую минуту (таймер не останавливается при выключении приложения)

Я новичок и не знаю, как прописать данную функцию

When the user suspends or quits the app, save the time to a file. When the app resumes or is reopened, compare this to the current time to calculate how much time elapsed, and therefore how much to reduce hunger by.

When the user suspends or quits the app, save the time to a file. When the app resumes or is reopened, compare this to the current time to calculate how much time elapsed, and therefore how much to reduce hunger by.