changing over real time

I’m looking for a way to change a value over real time so if the player stops playing the time still goes like in farmville or clash of clans. Any suggestions?