c语言strftime demo
time.h 格式化日期
time()获取当前日期的秒,localtime()获取当前时间字段, strftime格式化日期到字符串
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <time.h>
int main() {
time_t rawtime;
struct tm *timeInfo = NULL;
char buff[80];
time(&rawtime);
printf("rawtime:%d\n", rawtime);
timeInfo = localtime(&rawtime);
strftime(buff, sizeof(buff),"%Y-%m-%d %H:%M:%S", timeInfo);
printf("buff:%s\n", buff);
return 0;
}

Please call me JiangYouDang!
浙公网安备 33010602011771号