Linux获取系统当前时间函数:
实现方法一:
void debug_print_time(void) {
struct timespec time;
struct tm nowTime;
clock_gettime(CLOCK_REALTIME, &time); //获取相对于1970到现在的秒数
localtime_r(&time.tv_sec, &nowTime);
printf("\n系统时间:%04d-%02d-%02d %02d:%02d:%02d\n", nowTime.tm_year + 1900, nowTime.tm_mon + 1, nowTime.tm_mday, nowTime.tm_hour, nowTime.tm_min, nowTime.tm_sec);
}