Re: Translation from Unix raw time to normal time...

From: John Dilley (jad@akamai.com)
Date: Mon Dec 27 1999 - 13:36:57 MST


Dear 8823559,

I thought Unix time format was the normal time format... What other format
could you mean? (See below :)

----- Original Message -----
From: 8823559 <gis88559@cis.nctu.edu.tw>
To: <polygraph@ircache.net>
Cc: 8823559 <gis88559@cissun54.cis.nctu.edu.tw>
Sent: Monday, December 27, 1999 11:14 AM
Subject: Translation from Unix raw time to normal time...

>
> Hi:
>
> Is there any tool to convert Unix Raw Time to normal time
> format?...
>
> Thank you very much...:)

Just in case that wasn't the answer you were looking for here's a little
code that takes a Unix timestamp and prints out its ASCII representation in
your local timezone and in UTC (GMT). Best regards,

==jad==

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

void
print_time(time_t tval)
{
  char local[32], utc[32];

  strcpy(local, asctime(localtime(&tval)));
  strcpy(utc, asctime(gmtime(&tval)));
  printf("time_t %10d = %s UTC equivalent = %s", tval, local, utc);

  return;
}

int
main(int argc, char *argv[])
{
  int arg;

  if (argc == 1)
    print_time(time(0));
  else {
    for (arg=1; arg<argc; ++arg)
      print_time(atoi(argv[arg]));
  }
  exit(0);
}



This archive was generated by hypermail 2b29 : Tue Jul 10 2001 - 12:00:10 MDT