time_t是一个在time.h中定义好的结构体。原形如下:
struct tm
{
int tm_sec;//seconds 0-61
int tm_min;//minutes 1-59
int tm_hour;//hours 0-23
int tm_mday;//day of the month 1-31
int tm_mon;//months since jan 0-11
int tm_year;//years from 1900
int tm_wday;//days since Sunday, 0-6
int tm_yday;//days since Jan 1, 0-365
int tm_isdst;//Daylight Saving time indicator
};
void mygettime()
{
time_t t;
struct tm *tm_t;
time(&t);
tm_t=localtime(&t);
printf("the current time is:%02d:%02d:%02d\n",tm_t->tm_hour,tm_t->tm_min,tm_t->tm_sec);
printf("the current day is:%4d:%02d:%02d\n",
printf("the current day is:%d:%2d:%2d\n",
tm_t->tm_year+1900,tm_t->tm_mon+1,tm_t->tm_mday); //这边得自己手动加个1990,和加个 1,因为。。。见定义。。。
}