评论

收藏

[C++] c date格式

编程语言 编程语言 发布于:2021-08-07 13:45 | 阅读数:437 | 评论:0

//
// 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;
}


关注下面的标签,发现更多相似文章