zoukankan      html  css  js  c++  java
  • linux时间编程

    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 */

    };

  • 相关阅读:
    java.lang.NoSuchMethodError:antlr.collections.AST.getLine() I
    T7 java Web day01 标签HTML
    T6 s1 day19
    T5 s5 Day18
    T5 s4 Day 17
    T5 s3 day16
    T5 s2 Day 15
    T5 s1 day14
    T4 S03 day 12
    T4 S01 day1
  • 原文地址:https://www.cnblogs.com/bettercoder/p/3379150.html
Copyright © 2011-2022 走看看