用于写日志的时间格式

#include "stdafx.h"
#include <time.h>


int _tmain(int argc, _TCHAR* argv[])
{
	TCHAR szTime[32];
	memset(szTime, 0, sizeof(szTime));

	tm		*gmt;
	time_t osTime= time(0);
	gmt = localtime(&osTime);

	_stprintf ( szTime ,"[%d.%02d.%02d_%02d:%02d:%02d]" ,
		gmt->tm_year+1900, 
		gmt->tm_mon+1, 
		gmt->tm_mday, 
		gmt->tm_hour, 
		gmt->tm_min, 
		gmt->tm_sec );

	return 0;
}

  

posted @ 2012-11-21 14:38  曾经的碎片  阅读(296)  评论(0编辑  收藏  举报