转自:https://blog.csdn.net/u010087712/article/details/50731222
1.localtime_r
用来获取系统时间,运行于linux平台下。
函数原型:
struct tm *localtime_r(const time_t *timep, struct tm *result);
例子:
#include <stdio.h> #include <time.h> int main() { time_t time_seconds = time(0); struct tm now_time; localtime_r(&time_seconds, &now_time); printf("%d-%d-%d %d:%d:%d\n", now_time.tm_year + 1900, now_time.tm_mon + 1, now_time.tm_mday, now_time.tm_hour, now_time.tm_min, now_time.tm_sec); }
两个参数,第一个是time_t,第二个是一个tm类型的指针。
标签:include,struct,学习,tm,time,now,localtime From: https://www.cnblogs.com/BlueBlueSea/p/16856312.html