Hello Guys!
I’m trying to make a function to give an award every hour and every day.
For that I want to implement a function that given 2 DateTime check how many hours/days passed.
I already have a Coroutine to call that function every second.
For example, I want to give awards every 00:00:00, 01:00:00 … 12:00:00 … 23:00:00
Example:
DateTime date0 = new DateTime(2018, 8, 9, 20, 59, 59);
DateTime date1 = new DateTime(2018, 8, 9, 21, 0, 0);
int hoursPassed = (int) date1.Subtract(date0).TotalHours;
Debug.Log("Hours "+ hoursPassed);
The hoursPassed will be equal to 0 in this case. I want to make a function (maybe already exists) that retrieve me 1 instead. The same with the days.
Example 2
DateTime date0 = new DateTime(2018, 8, 9, 23, 59, 59);
DateTime date1 = new DateTime(2018, 8, 10, 00, 00, 00);
int DaysPassed = (int) date1.Subtract(date0).TotalDays;
Debug.Log("Days "+ DaysPassed);
It will retrieve 0 and I want to retrieve 1.
I also want this to work when multiple hours/days have passed .
Can anybody help me?
Thank you