--- In [email protected], "Tyler Littlefield" <ty...@...> wrote:
>
> Hello list,
> I've got a quick question;
> I'm using ctime for logs, and want to cut down on it somewhat, so it won't 
> show the date. Maybe just something that will show like 3 hours 5 minutes 
> ago, or something similar, or possibly just a shortened form of the date.
> Does the standard library have something that I could use to do this with?

You could use gmtime() to set a structure containing all the time fields and 
just print out the ones you want eg.

#include <stdio.h>
#include <time.h>

int main(void)
{
    time_t t = time(NULL);
    struct tm *tm = gmtime(&t);


    printf("time: yr=%d h=%d m=%d s=%d\n",
        tm->tm_year + 1900, tm->tm_hour, tm->tm_min, tm->tm_sec);

    return 0;
}

> The program is in c, if that makes much of a difference.

Good - a proper program :-)

Reply via email to