Health bar depletes when app isn't open

I’m familiar with how to create a health bar the depletes over time within the app but how do I make this continue when the app isn’t being used?

Think of an app similar to The Sims or a pet feeding game where you come back after an hour or so and the bar has depleted.

In OnApplicationQuit/OnApplicationPause or wherever you think is the best place for your game. Store the current time in player prefs, when your game starts again, check to see if that key is stored, if it is, calculate how much time has passed and set your health bar.