分类: LINUX
2015-01-14 13:48:23
#includemain() { time_t timep; time (&timep); printf(“%s”,asctime(gmtime(&timep))); }
#includemain() { 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); }
#includemain(){ 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); }
#includemain() { time_t timep; strcut tm *p; time(&timep); printf(“time() : %d \n”,timep); p=localtime(&timep); timep = mktime(p); printf(“time()->localtime()->mktime():%d\n”,timep); }
#includemain() { int seconds= time((time_t*)NULL); printf(“%d\n”,seconds); }