获取电脑当前时间c++

#include <time.h>
#include <iostream>
using namespace std;


string make_daytime_string()
{
	time_t t = time(0); 
	char tmp[64]; 
	strftime( tmp, sizeof(tmp), "%d %m %Y %X %Z",localtime(&t) );
	string s =tmp;
	return s;
}


void main()
{
	string str = make_daytime_string();
	printf("%s\n", str.c_str());
}


你可能感兴趣的:(获取电脑当前时间c++)