Getlocaltime()

string Getlocaltime()
{
	time_t now_time;
	now_time = time(NULL);
	tm *pCurTime=NULL;
	pCurTime = localtime(&now_time);
	if (NULL == pCurTime)
	{
		return "";
	}

	stringstream stringtime;
	stringtime<<1900+pCurTime->tm_year<<"-"<tm_mon + 1<<"-"<tm_mday\
		<<" "<tm_hour<<":"<tm_min<<":"<tm_sec;

	string stime = stringtime.str();

	stringtime.str("");
	stringtime.clear();

	return stime;
}

你可能感兴趣的:(源码小函数集合)