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
", seconds);
    struct tm *date = NULL;
    date = localtime(&seconds);
    char dateBuff[1024];
    strftime(dateBuff, 1024, "%Y-%m-%d %H:%M:%S", date);
    printf("datebuff:%s
", dateBuff);

    return 0;
}

  

原文地址:https://www.cnblogs.com/luckygxf/p/12275911.html