• C实现将指定秒数转化为时:分:秒格式


    struct tm l_tm;
        time_t l_time = 61;
        gmtime_r(&l_time, &l_tm);
        char time_char[32];
        sprintf(time_char, "%02d:%02d:%02d",l_tm.tm_hour, l_tm.tm_min, l_tm.tm_sec);

    tm是C中的一个结构体,结构如下

    struct tm{

    int tm_sec;     //Seconds  [0-60]

    int tm_min;    //Minutes   [0-59]

    int tm_hour;   //Hours   [0-23]

    int tm_mday;   // Day   [1-31]

    int tm_mon;     //Month   [0-11]

    int tm_year;      //Year   -1900

    int tm_wday;     //Day  of week   [0-6]  一周中的第几天

    int tm_yday;       // Days  in year  [0-365]  一年中的第几天

    int tm_isdst;     //DST   [-1/0/1]  夏令时标示符,实行夏令时的时候,tm_isdst为正。不实行夏令时,tm_isdst为0,不了解情况时,tm_isdst为负

    #ifdef __USE_BSD

    long int tm_gmtoff;     //Seconds east of  UTC

    __const char* tm_zone;   //Timezone abbreviation

    #else

    long int __tm_gmtoff;     //Seconds east of UTC

    __const char* __tm_zone;  //Timezone abbreviation

    #endif

    }

    在C语言中
    有time_t tm  timeval等几种类型的时间

    time_t为typedef __int64 __time64_t

    timeval为

    struct timeval{

    uint tv_sec;

    uint tv.usec;

    }

  • 相关阅读:
    学习进度条73
    学习进度条72
    学习进度条71
    学习进度条70
    学习进度条69
    学习进度条68
    学习进度条67
    学习进度条66
    学习进度条65
    elasticsearch
  • 原文地址:https://www.cnblogs.com/arthas/p/2769343.html
Copyright © 2020-2023  润新知