Linux C 中获取local日期和时间 time()&localtime()函数
/* time - 获取计算机系统当前的日历时间(Calender Time)
* 处理日期时间的函数都是以本函数的返回值为基础进行运算
* 函数原型:
* #include <time.h>
* time_t time(time_t *calptr);
* 返回值:
* 成功:秒数,从1970-1-1,00:00:00
* 使用:
* time_t now;
* time(&now); // == now = time(NULL);
*/
/*
* localtime - 将时间数值变换成本地时间,考虑到本地时区和夏令时标志
* 函数声明:
* #include <time.h>
* struct tm * localtime(const time_t *timer);
*/
/* struct tm 结构
* 此结构体空间由内核自动分配,而且不需要去释放它
*/
struct tm {