Need help with checking system time for 24 hours passed?

I’m trying to add a daily minigame, but I have no idea how to check if 24 hours have passed since last time played.
I need to save system time to a variable after minigame is played and if 24 hours have passed set a boolean to true indicating 24 hours have passed.
Any ideas where to start?

UnityEngine.PlayerPrefs as an easy way to save and load values from persistent storage.

As for the time, System.DateTime.UtcNow to get the current absolute time. System.DateTime.Subtract() to get the difference between the current time and the saved time, to see if it is greater than or equal to a System.TimeSpan which represents 1 day, 0 hours, 0 minutes, 0 seconds. System.DateTime.ToString() and System.DateTime.Parse() for serializing the time. I’d recommend passing a the standard format string “yyyy-MM-ddTHH:mm:sszzz” to the ToString() method.

5 Likes

So i would save System.DateTime.UtcNow to a variable then check that against current time with System.DateTime.Subtract. and use System.TimeSpan to check how long has passed and if it equals 1 day then set a boolean that allows player to play minigame?