C库函数time_t time(time_t *seconds)返回自纪元(00:00:00 UTC,1970年1月1日)以来的时间,单位为秒。如果second不是NULL,则返回值也存储在变量second中。
time_t time(time_t *t)
C库函数tm *localtime(const time_t *timer)使用timer所指向的时间,用代表相应本地时间的值填充tm结构。timer的值被分解到结构tm中,并以当地时区表示。
Localtime不是线程安全的,程序中一般使用localtime_r
struct tm *localtime(const time_t *timep);
struct tm *localtime_r(const time_t *timep, struct tm *result);
struct tm {
int tm_sec; /* seconds, range 0 to 59 */
int tm_min; /* minutes, range 0 to 59 */
int tm_hour; /* hours, range 0 to 23 */
int tm_mday; /* day of the month, range 1 to 31 */
int tm_mon; /* month, range 0 to 11 */
int tm_year; /* The number of years since 1900 */
int tm_wday; /* day of the week, r