[LCP]time
Joachim Bauernberger
bj at gmx.net
Sat Jan 19 06:42:04 UTC 2002
Hi,
I am having a little problem with time. For some reason the code below will
have the following output:
[bjdev: C]$ ./time
12 41 10 23 11 35 1
Mon Dec 23 10:41:12 1935
The actual time however is:
[bjdev: C]$ date
Fre Jan 18 20:35:29 CET 2002
Can somebody be so kind and tell me what I am doing wrong (maybe it's time
for me to get some sleep .... :))
Here is the code:
#include <time.h>
#include <stdio.h>
int main( int argc, char **argv) {
time_t now;
struct tm *tt;
char *c;
tt = localtime(&now);
//c = ctime(&now);
fprintf(stdout,"%d %d %d %d %d %d %d\n",tt->tm_sec, tt->tm_min,
tt->tm_hour, tt->tm_mday, tt->tm_mon, tt->tm_year, tt->tm_wday);
//fprintf(stdout,"\n%s\n",c);
c = asctime(tt);
fprintf(stdout,"%s\n",c);
return 0;
}
--
You can get my public pgp key here:
http://www.mxscan.com/pgp/joachim.asc
PGP fingerprint:
25 96 E0 25 48 D9 8E 10 3C C0 48 E7 AF 5A E2 C6 A3 15 05 E6
More information about the linuxCprogramming
mailing list