: ex_time.c
                          
                          time(2)  ctime(2)
 1 #include <sys/types.h>
 2 #include <stdio.h>
 3 #include <time.h>
 4 #include <stdlib.h>
 5 extern char *tzname[];
 6
 7 main()
 8 {
 9     time_t now;
10     struct tm *sp;
11
12     (void) time( &now );
13
14     printf("%s", ctime( &now ) );
15
16     sp = localtime(&now);
17     printf("%d/%d/%02d %d:%02d %s\n",
18         sp->tm_mon + 1, sp->tm_mday,
19         sp->tm_year, sp->tm_hour,
20         sp->tm_min, tzname[sp->tm_isdst]);
21     exit(0);
22 }