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

    };

  • 相关阅读:
    redis 下载安装
    Docker之网络
    容器与镜像
    Docker之容器
    Docker之镜像
    在安装完windows和linux双系统后,删除BIOS中的引导启动项在Window下
    Ububtu 18.04中如何在火狐浏览器中安装flash插件
    lambda 表达式
    IDEA DeBug mode
    spring 系统启动加载的类
  • 原文地址:https://www.cnblogs.com/bettercoder/p/3379150.html
Copyright © 2011-2022 走看看