Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I already found difftime between now and the highest value of time_t. I would like to know how I can format the value into years, months, days, hours, and minutes.
Thanks.

Hi:
Take a look at the tm structure in the time.h header file. Here's a stub program using some of the functions:
Regards,
Nails
#include
#includemain()
{
struct tm *old, *new;
time_t tloc, newtloc; /* generally time_t is a long */time(&tloc); /* get time in seconds since EPOCH */
printf("time in seconds since EPOCH is %ld\n", tloc);old=localtime(&tloc); /* convert seconds to date structure */
printf("year is %d\n",old->tm_year);
printf("month is %d\n",old->tm_mon+1);
printf("day is %d\n",old->tm_mday);
printf("hour is %d\n",old->tm_hour);
printf("min is %d\n",old->tm_min);new=old;
newtloc=mktime(new); /* convert structure to seconds */
if(newtloc == tloc)
printf("they're equal\n");}

![]() |
binary to ASCII
|
Group differs in
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |