1.首先包含头文件
#include <time.h>
2.直接上代码
time_t temp;
time(&temp);
struct tm* curTime;
curTime = localtime(&tt);
printf("%d/%d/%d %d:%d:%d",curTime->tm_year + 1900,curTime->tm_mon + 1,curTime->tm_mday,curTime->tm_hour,curTime->tm_min,curTime->tm_sec );