CodeSarang.Com
Home | All categories Join | Login | 검색   

 

time_t 를 이용하여 날짜/시간 얻기

등록자 : cpueblo (유광희), 2008-08-14
글수정 | 글삭제


Intro

time_t 와 localtime 을 이용하여 얻은 시간을 CString 으로 반환해 줍니다.

namespace cpueblo { CString GetDateTimeString() { time_t t; time(&t); struct tm today = *localtime(&t); CString TimeString; TimeString.Format("%04d-%02d-%02d %02d_%02d_%02d", today.tm_year + 1900, today.tm_mon + 1, today.tm_mday, today.tm_hour, today.tm_min, today.tm_sec); return TimeString; } }

Usage

TRACE(cpueblo::GetDateTimeString()); CString CurrentDateTime = cpueblo::GetDateTimeString();

Result

2008-09-16 18_48_07

Keywords

today->tm_year
time_t
localtime





글수정 | 글삭제
http://codesarang.com. mail to cpueblocpueblo.com