1. 程式人生 > >獲取電腦當前時間c++

獲取電腦當前時間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());
}