Is there a way to calculate how much time has passed when I close the game and reopen it?
Have you checked the solution in this thread?
wow thank you so much for some reason i never met this thank you so much
Well let us know if you need more examples, because that topic is based on just comparing a set amount of time to see if current time meets or exceeds it. There is an extra step you have to take if you want to see how much time the player is gone, to calculate “offline earnings” for example. In that case, assuming you have a pretty decent save system going on, you load the saved time at the beginning of the game (if it exists in storage), then subtract that from current timestamp and use the remainder in your calculations.