Struct (Path Standard C Header / time.h)

tm

struct { ... } tm;

Structure to hold time and date


Using In

  char* asctime(struct tm *timeptr);
    Returns a pointer to a string representing the date and time of the structure struct timeptr

  time_t mktime(struct tm *timePtr);
    Transfer tm to time_t

  int strftime(char *string, size_t maxSize, char *format, struct tm *timePtr);
    Formats the time represented by the structure timeptr according to the formatting rules defined in format and stores it in str.

  char* strptime(char *string, char *format, struct tm *timePtr);
    Convert a string to a time type according to a specific time format

  struct tm* gmtime_r(time_t *timePtr, struct tm *result);
    Same to gmtime (Thread Safe)

  int timegm(struct tm *timePtr);
    Transfer tm to time_t

结构体 (属于 标准C头文件 / time.h)

tm

struct { ... } tm;

用来保存时间和日期的结构


被用于

  char* asctime(struct tm *timeptr);
    返回一个指向字符串的指针,它代表了结构 struct timeptr 的日期和时间

  time_t mktime(struct tm *timePtr);
    将tm转换为time_t

  int strftime(char *string, size_t maxSize, char *format, struct tm *timePtr);
    根据 format 中定义的格式化规则,格式化结构 timeptr 表示的时间,并把它存储在 str 中

  char* strptime(char *string, char *format, struct tm *timePtr);
    按照特定时间格式将字符串转换为时间类型

  struct tm* gmtime_r(time_t *timePtr, struct tm *result);
    等同于 gmtime (Thread Safe)

  int timegm(struct tm *timePtr);
    从tm转换为time_t