char* asctime(struct tm *tmp)
1.0、参考
1.1、此函数的作用

得到格式化的时间,格式为星期 月 日 小时:分:秒 年

1.2、参数说明

struct tm的定义:

struct tm {
    int tm_sec;   /* seconds [0,60] */
    int tm_min;   /* minutes [0,59] */
    int tm_hour;  /* hours   [0,23]*/
    int tm_mday;  /* day of the month [1,31] */
    int tm_mon;   /* month   [0,11] */
    int tm_year;  /* year since 1900 */
    int tm_wday;  /* day of the week [0,6] (Sunday =0) */
    int tm_yday;  /* day in the year [0,365] */
    int tm_isdst; /* daylight saving time */
};
1.3、返回值说明

得到格式化的时间,格式为星期 月 日 小时:分:秒 年

1.4、使用示例
#include <stdio.h>
#include <time.h>

int main() {
    time_t tt = time(NULL);
    struct tm *tms = localtime(&tt);
    char *str = asctime(tms);
    printf("现在是:%s", str);
    return 0;
}

使用cc命令编译 ⤵︎

cc -o test_time test.c

运行结果如下 ⤵︎

Mon Mar 18 12:13:22 2019