GetSystemTime This function retrieves the current system date and time. The system time is expressed in Coordinated Universal Time (UTC). void GetSystemTime( LPSYSTEMTIME lpSystemTime ); Parameters lpSystemTime [out] Pointer to a SYSTEMTIME structure to receive the current system date and time.
Return Values None.
或者time_t CStnTimerWnd::GetCurrTime(void) { time_t tmRetVal=0; ::time(&tmRetVal); // Get time as long integer. return tmRetVal; }
http://www.vctop.com/View.Asp?ID=246&CateID=1
void GetSysTime(CString &StrTime) { CTime time = CTime::GetCurrentTime(); int year,month,day,hour,minute,second; year = time.GetYear(); day = time.GetDay(); month = time.GetMonth(); hour = time.GetHour(); minute = time.GetMinute(); second = time.GetSecond(); CString m_time; CString strsql; m_time.Format("%d-%d-%d %d:%d:%d",year,month,day,hour,minute,second); StrTime = m_time; }
CTime t = CTime::GetCurrentTime();strTime.Format("%02d-%02d-%02d %02d:%02d:%02d",t.GetYear(), t.GetMonth(),t.GetDay(),t.GetHour(),t.GetMinute(),t.GetSecond()); AfxMessageBox(strTime);
CString TimeText=time.Format("%Y年%m月%d日");
This function retrieves the current system date and time. The system time is expressed in Coordinated Universal Time (UTC). void GetSystemTime(
LPSYSTEMTIME lpSystemTime ); Parameters
lpSystemTime
[out] Pointer to a SYSTEMTIME structure to receive the current system date and time.
Return Values
None.
{
time_t tmRetVal=0; ::time(&tmRetVal); // Get time as long integer. return tmRetVal;
}
{
CTime time = CTime::GetCurrentTime();
int year,month,day,hour,minute,second;
year = time.GetYear();
day = time.GetDay();
month = time.GetMonth();
hour = time.GetHour();
minute = time.GetMinute();
second = time.GetSecond();
CString m_time;
CString strsql;
m_time.Format("%d-%d-%d %d:%d:%d",year,month,day,hour,minute,second);
StrTime = m_time;
}
t.GetMonth(),t.GetDay(),t.GetHour(),t.GetMinute(),t.GetSecond());
AfxMessageBox(strTime);