How To Tell How Much Time Has Passed?
A quick question that probably has a simple answer. Using the datetime functions (https://docs.unrealengine.com/latest/INT/BlueprintAPI/Math/DateTime/index.html)
How can I tell how many minutes have passed?
I have a save file for a game, which stores the datetime that it was created. I'd like to check the difference in time between the save files datetime and the current time to see if it's been more than say, ten minutes. If it has, do this, if it hasn't, do that.
Any help is appreciated!
asked Sep 12 '15 at 06:58 AM in Blueprint Scripting
There are two ways to do this:
One is to get the actual system time (as you probably did) using the Now node, which returns a Date Time Structure, presumably something of the form Year-Month-Day-Hour-Minute-Second. Given such a Date Time Structure, you can then query the elements (GetDay, GetHour, GetMinute). So you could implement a function that checks the difference between two such structures by comparing all the date elements. You'll need to pay attention to overflows: obviously more than ten minutes have passed from 15:23 to 15:42, but the same is true for 15:57 to 16:08. When testing your function, you can manipulate your system clock to test whether you catch all such cases correctly. (Or you might decide that it's okay if there are some edge cases, such as rolling past midnight, where you just don't care.)
Alternatively, you could use Get Real Time Seconds (since the session has started) and compare the differences between two second counts. Converting to minutes is easy in this case.
answered Sep 12 '15 at 08:17 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here