Seasons.NET

ちょっとした技術ブログです

日付の取得方法

ちょっと日付取得方法を調べたのでメモ。

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

int _tmain(int argc, _TCHAR* argv[])
{
	time_t now;
	struct tm t;
	time( &now );
	if( localtime_s( &t , &now ) )
	{
		printf( "失敗しました\n" );
		return 1;
	}
	printf( "Today : %d-%02d-%02d-%02d-%02d-%02d\n" , 
		t.tm_year + 1900,
		t.tm_mon,
		t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec );
	return 0;
}