1.time_t time(time_t *t)

功能:

成功:返回日历时间,单位为秒
失败:返回-1

  

2.struct tm *gmtime(const time_t *timep)

功能:

成功:将参数timep所指定的日历时间转换为世界标准时间(即格林威治时间)

失败:返回NULL

struct tm

{

  int tm_sec;

  int tm_min;

  int tm_hour;

  int tm_mday    /* day of the month */

  int tm_mon;    

  int tm_year;

  int tm_wday;    /* day of the week */

  int tm_yday;    /* day in the year */

  int tm_isdst;    /* daylight saving time */

};

 

3.struct tm* localtime(const time_t *timep)

功能:

成功:返回本地时间
失败:返回NULL

 

4.char *asctime(const struct tm* tm)

功能:

成功:返回以字符串形式表示的本地时间
失败:返回NULL

 

5.int gettimeofday(struct timeval *tv,struct timezone *tz)

功能:

成功:返回0,在tv指向的结构体中保存获取的微秒级别的时间
失败:返回-1

tz:已被废弃,设为NULL

struct timeval

{

  time_t tv_sec;        /* seconds */

  suseconds_t tv_usec;    /* microseconds */

};

posted on 2013-10-20 16:16  运动和行动  阅读(193)  评论(0编辑  收藏  举报