#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <ctype.h>
#include <sys/stat.h>
void getdate(char *datestr,char *format)
{
	time_t nnowtime = time(NULL);
	struct tm* ptmTemp = localtime(&nnowtime);
	if (ptmTemp == NULL ||
		!strftime(datestr, 256, format, ptmTemp))
		datestr[0] = '\0';
}
#include <iostream>
using namespace std;
int main()
{
    char szdate[64]={0};
    char sztime[64]={0};
    getdate(szdate, "%Y%m%d");
    getdate(sztime, "%H%M%S");
    std::cout<<szdate<<std::endl;
    std::cout<<sztime<<std::endl;
    return 0;
}
 
![]()