时间函数应用 time
| function 定义 | 含义 | 返回值 | 精度 |
|---|---|---|---|
| time() | time 函数获得从 1970 年 1 月 1 日 0 点到当前的秒数,存储在time_t结构之中。 | time_t | 秒 |
| gettimeofday() | gettimeofday 函数返回从 1970 年 1 月 1 日 0 点以来,到现在的时间。用 timeval 数据结构表示。 | struct timeval{ time_t tv_sec; long int tv_usec;}; | 微秒 |
| clock_gettime() | clock_gettime 函数返回从 1970 年 1 月 1 日 0 点以来,到现在的时间。用 timespec 数据结构表示。 支持不广泛。属于实时扩展。 | struct timespec{ time_t tv_sec; long int tv_nsec;}; | 纳秒 |
| ftime() | 函数返回从 1970 年 1 月 1 日 0 点以来,到现在的时间。用timeb数据结构表示。已经过时, 被 time() 替代。尽量不使用。 | struct timeb {time_t time;unsigned short millitm;short timezone;short dstflag;}; | 毫秒 |
注意: ftime()基本已经不再使用,目前系统中保留只为兼容以前的系统。
浙公网安备 33010602011771号