time格式化时间

cooolr 于 2022-03-30 发布
#include <time.h>
#include <stdio.h>

int main() {
    time_t now;
    char format_time[20];
    time(&now);
    strftime(format_time, 20, "%Y-%m-%d %H:%M:%S", localtime(&now));
    printf("%s\n", format_time);
}