1) GETTIMEOFDAY
struct timeval nowtime;
gettimeofday(&nowtime,NULL);
printf("%d, %d\n", nowtime.tv_sec, nowtime.tv_usec);
2) CLOCK_GETTIME()
struct timespec time;
clock_gettime(CLOCK_MONOTONIC, &time);
printf("%d, %d\n", time.tv_sec, time.tv_nsec);
-- 참고 --
CLOCK_MONOTONIC: 특정 시점을 기준으로 한 시각(부팅 후부터의 시각)
CLOCK_REALTIME: 년월일의 날짜
struct timeval nowtime;
gettimeofday(&nowtime,NULL);
printf("%d, %d\n", nowtime.tv_sec, nowtime.tv_usec);
2) CLOCK_GETTIME()
struct timespec time;
clock_gettime(CLOCK_MONOTONIC, &time);
printf("%d, %d\n", time.tv_sec, time.tv_nsec);
-- 참고 --
CLOCK_MONOTONIC: 특정 시점을 기준으로 한 시각(부팅 후부터의 시각)
CLOCK_REALTIME: 년월일의 날짜