#include main(){time_t timep;time (&timep);printf(“%s”,asctime(gmtime(&timep)));}
#include main(){time_t timep;time (&timep);printf(“%s”,ctime(&timep));}
#include #include main(){struct timeval tv;struct timezone tz;gettimeofday (&tv , &tz);printf(“tv_sec; %d\n”, tv,.tv_sec) ;printf(“tv_usec; %d\n”,tv.tv_usec);printf(“tz_minuteswest; %d\n”, tz.tz_minuteswest);printf(“tz_dsttime, %d\n”,tz.tz_dsttime);}
#include #include main(){struct timeval tv;struct timezone tz;gettimeofday (&tv , &tz);printf(“tv_sec; %d\n”, tv,.tv_sec) ;printf(“tv_usec; %d\n”,tv.tv_usec);printf(“tz_minuteswest; %d\n”, tz.tz_minuteswest);printf(“tz_dsttime, %d\n”,tz.tz_dsttime);}
#include main(){char *wday[]={“Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”};time_t timep;struct tm *p;time(&timep);p=lotime(&timep); /*取得当地时间*/printf (“%d%d%d ”, (1900+p->tm_year),( l+p->tm_mon), p->tm_mday);printf(“%s%d:%d:%d\n”, wday[p->tm_wday],p->tm_hour, p->tm_min, p->tm_sec);}
#include main(){time_t timep;str tm *p;time(&timep);printf(“time() : %d \n”,timep);p=localtime(&timep);timep = mktime(p);printf(“time()->localtime()->mktime():%d\n”,timep);}
#include main(){int seconds= time((time_t*)NULL);printf(“%d\n”,seconds);}