影者东升 发表于 2021-8-7 13:45:23

c date格式

//
// Created by gxf on 2020/2/8.
//
#include <time.h>
#include <stdio.h>

int main(int argc, char **argv) {
    time_t seconds;
    time(&seconds);
    printf("seconds:%d\n", seconds);
    struct tm *date = NULL;
    date = localtime(&seconds);
    char dateBuff;
    strftime(dateBuff, 1024, "%Y-%m-%d %H:%M:%S", date);
    printf("datebuff:%s\n", dateBuff);

    return 0;
}



文档来源:51CTO技术博客https://blog.51cto.com/u_2498536/3304106
页: [1]
查看完整版本: c date格式