<time.h> How can I translate time into days months and years?
| Plazmotech (12) |
|
|
For example, if I have a time 99248, thats 1 day, 3 hours, 34 minutes. How do I get it to display that?
|
|
|
| James2250 (245) |
|
I am not sure about a function to do it for you, but it isn't that hard to code it yourself quickly.
1 2 3
|
int Days = 99248 / 60 / 60 / 24;
int Hours = (99248 / 60 / 60) % 24;
int Minutes = (99248 / 60) % 60;
|
|
|
|
| andywestken (1950) |
|
From http://www.cplusplus.com/reference/ctime/
You can convert the time_t to a struct tm, which has member for days, ..., hours, minutes, ...
gmtime Convert time_t to tm as UTC time
localtime Convert time_t to tm as local time |
Then you can format the time using
strftime Format time as string |
Andy
|
|
Last edited on
|