获取struct tm中的时间

    #include <time.h>
time_t tval;
struct tm *ptm;        
time(
&tval);
ptm 
= localtime(&tval);
int year = ptm->tm_year + 1900//
int mon = ptm->tm_mon + 1//

int day = ptm->tm_mday; //日
int hour = ptm->tm_hour; //
int min = ptm->tm_min; //
int sec = ptm->tm_sec;//

你可能感兴趣的:(struct)