time函数返回当前时间和日期。
#include <time.h>
time_t time(time_t *calptr);
时间值总是作为函数值返回。如果参数不为空,则时间值也存放在由calptr指向的单元内。
gettimeofday提供了更高的分辨率(最高为微秒级)
int gettimeofday(struct timeval *restrict tp, void *restrict tzp);
localtime和gmtime可将日历时间转换成以年、月、日、时、分、秒、周日表示的时间。
struct tm *gmtime(const time_t *calptr);
struct tm *localtime(const time_t *calptr);
localtime将日历时间转换成本地时间,而gmtime则将日历时间转换成国际标准时间(0时区)。
mktime以本地时间的年、月、日等作为参数,将其转换成time_t值。
time_t mktime(strcut tm *tmptr);
asctime和ctime函数产生26字节的字符串,如Tue Feb 10 18:27:38 2004\n\0
char *asctime(const struct tm *tmptr);
char *ctime(const time_t *calptr);
strftime是非常复杂的类似于printf的时间值函数。
size_t strftime(char *restrict buf, size_t maxsize, const char *restrict format, const struct tm *restrict tmptr);