(int)Time.time % 60; gives me seconds and (int)Time.time / 60; gives me minutes. What is the equivalent for hours?
(int)Time.time % 60;
(int)Time.time / 60;
(int)Time.time % 60; gives me seconds and (int)Time.time / 60; gives me minutes. What is the equivalent for hours?
(int)Time.time % 60;
(int)Time.time / 60;
Of course to get hours you just need to use 3600 (60*60). Btw in your case you get absolute minutes. So for example if you run the game for two hours and 30 minutes Time.time/60 returns “150”.
If you need days, hours, minutes, seconds It’s easier to do it in seperate steps:
float t = Time.time;
int sec = (int)(t%60);
t /= 60;
int minutes = (int)(t%60)
t /= 60;
int hours = (int)(t%24)
t /= 24;
int days = (int)t;
edit Here’s an example with direct values:
float t = Time.time;
int sec = (int)(t%60);
int minutes = (int)((t/60)%60)
int hours = (int)((t/3600)%24)
int days = (int)(t/86400); // There are 86400 seconds in a day (60*60*24)