Time elapsed when app is closed

hi guys I’m doing a tamagotchi game, and I have the problem that if the app stays in standby or is closed, I do not actually shoot the timer.
The only way is to make control variables through save with playerpref.
Each face that launches the app uploads the data and makes a ceck.

It’s correct?

For the time I’m using the system.data.hour

Thank you

firstly, playerprefs are things to stay FAR away from when storing game data like that. The most you should use them for is saving settings like volume ect. I would recommend watching this unity tutorial on data persistence, there a few examples in the video and i would recommend that you do the one that uses the serializer. So once you have the date stored you can check the date when th user next login, and do some simple math to work out the difference between the two dates