- Home /
Hours elapsed with system datetime.now.hours
Hello what's the best way for calculate the time elapsed from when save and load a datetime.now.hours value?
Exactly I want to know if since I saved to when I loaded have passed more than 8 hours.
Thank you
Answer by HarryMcCaffery · Oct 26, 2018 at 09:55 PM
Store the full time and date from System.DateTime.Now; dont just store the hours value, but the full time and date. When you reload the game, and want to calculate the elapsed time, subtract the stored values from the current ones to get the elapsed time. If the hours are greater than 8, or if the days or years are greater than 1, you know that more than 8 hours have elapsed.
Answer by mustang4484 · Oct 27, 2018 at 11:31 AM
Ok thank you It's possibile subtraction of two strings or I have to convert them first?
You'd have to convert the strings. System.datetime.hour etc should already return integers.