Linux下用C获取当前时间
Linux下用C获取当前时间,具体如下: 代码(可以把clock_gettime换成time(NULL)) void getNowTime() { timespec time; clock_gettime(CLOCK_REALTIME, &time); //获取相对于1970到现在的秒数 tm nowTime; localtime_r(&time.tv_sec, &nowtime); char current[1024]; sprintf(current, dddd:d:d, nowTime.tm_year + 1900, nowTime
下载地址
用户评论