struct tm {
int tm_sec; /* seconds */
int tm_min; /* minutes */
int tm_hour; /* hours */
int tm_mday; /* day of the month , in the range 1 to 31*/
int tm_mon; /* month,in the range 0 to 11 */
int tm_year; /* year since 1900 */
int tm_wday; /* day of the week, in the range 0 to 6*/
int tm_yday; /* day in the year , in the range 0 to 365*/
int tm_isdst; /* daylight saving time */
};
常用方发:
- time_t t = time(NULL);
- struct tm *tt = localtime(&t);
time(NULL)函数获取从1970-1-1 0:00到现在所经历的秒数,可以time(&t),而不获取返回值
localtime(&t)函数将该时间按转化为本地时间,存放在struct tm结构体中,返回该结构体的指针。
通过返回的指针来获取相应的时间项~
阅读(1926) | 评论(0) | 转发(0) |