标签:
time函数
#include<time.h>
time_t time(time_t *t);
time() returns the time as the number of secs since 1970-01-01 00:00:00 +0000(UTC)
假如参数t不是NULL,返回值(秒数)(日历时间)也存储在t中。
失败返回-1.
#include <time.h>
char *ctime(const time_t *time);
将秒数转化为具体日期(ASCII),长度固定26字节。
the time is 1449579811
the time ascii is Tue Dec 8 21:03:31 2015
等价:asctime(localtime(t));
Broken-down time is stored in the structure tm whichi is deiined in time.h as follows:
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
tm_year指的是自1900年以来的年数。
char *asctime(const struct tm *tm);
将分离时间装换为字符串时间。
struct tm *localtime(const time_t *timep);
将秒数装换为分离时间。
struct tm *gmtime(const time_t *timep);
time_t mktime(struct tm *tm);
将分离时间转换为秒数。
double difftime(time_t time1, time_t time0);
The difftime() function returns the number of seconds elapsed between time time1 and time time0, represented as a double. Each of the times is specified in calendar time, which means its value is a measurement (in seconds) relative to the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
clock_t clock(void);
DESCRIPTION
The clock() function returns an approximation of processor time used
by the program.
RETURN VALUE
The value returned is the CPU time used so far as a clock_t; to get
the number of seconds used, divide by CLOCKS_PER_SEC. If the proces‐
sor time used is not available or its value cannot be represented, the
function returns the value (clock_t) -1.
标签:
原文地址:http://www.cnblogs.com/embedded-linux/p/5031179.html