Timespan problems

Hello everyone who is reading this post. I have problem with game I develop. Player has to manage characters to farm coins. Coins could be farmed even when game is closed. To my mind the easiest way to do that just count the time difference between now(player opens the game) and the last time when player closed the game. Everything is fine when player starts the game after some time, but when the date passes to the next month time difference counts incorectly. So how could I take into consideration that month changed?