Hello,
thanks. I wasn't aware that would work. You've saved me lots of work. I was 
thikning something along the lines of a 150 line function that split the thing 
up its self and dreading it. :)


Thanks,
Tyler Littlefield
Web: tysdomain.com
email: [email protected]
My programs don't have bugs, they're called randomly added features.

  ----- Original Message ----- 
  From: John Matthews 
  To: [email protected] 
  Sent: Saturday, March 21, 2009 3:34 AM
  Subject: [c-prog] Re: cutting down on output from ctime


  --- 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 :-)



  

[Non-text portions of this message have been removed]

Reply via email to