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[1024];
    strftime(dateBuff, 1024, "%Y-%m-%d %H:%M:%S", date);
    printf("datebuff:%s\n", dateBuff);

    return 0;
}

  

posted on 2020-02-08 11:52  luckygxf  阅读(508)  评论(0编辑  收藏  举报

导航