CString szTime;
CTime time = CTime::GetCurrentTime();
szTime.Format("%2d:%02d", time.GetHour(), time.GetMinute());
<你的Edit>SetWindowText(szTime);
CTime time = CTime::GetCurrentTime();
szTime.Format("%2d:%02d", time.GetHour(), time.GetMinute());
<你的Edit>SetWindowText(szTime);
解决方案 »
- 请教一个关于vc2008 msdn使用的问题
- 往EXCEL中增加几个字段会显示“字段定义语法错误”,急!!!
- 实在找不到这三句话的溢出问题,请大哥帮忙
- 请问如何用vc制作类似MediaPlayer的进度条?
- 如何在vs2005 Setup Project中注册com组件
- 如果一个函数是全局函数,为什么不能使用MFC的成员函数?请问:
- 英文版xp支持ODBC的Requery()的查询吗?
- VC++里能用汇编写的代码吗?这么用?
- 接点私活做,有的联系我。
- 那位大侠能帮助我解决RPG游戏中关于打斗公式的算法?谢谢!
- VisualC++技术内幕第四版好还是第五版好?
- 请问在位图区域怎不能响应OnMouseMove事件?
GetCurrentTime是当前时间
CTime time = CTime::GetCurrentTime();
time.Format("%x");
m_Edit.SetWindowText(time);
cout<<"current time is "<<curTime.Format("%A, %B %d, %Y")<<"\n";
cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
SYSTEMTIME pTime;
::GetSystemTime(&pTime);
cout<<"current time is" << pTime.wMilliseconds<<" " << pTime.wMinute<<" " <<pTime.wHour<<
" " << pTime.wDay << " " << pTime.wMonth << " " << pTime.wYear<<endl;TWO method can get all current time!
m_TIME=time.Format("%A,%B/%d/%Y,%H:%M:%S");
UpdateData(false);
//上面的m_TIME是我定义的edit控件名称。
SYSTEMTIME time;
自己用MSDN查一嚇就知啦
CString str=Timer.Format(" %Y-%m-%d %H:%M:%S ");CSDN:
CTime::Format
CString Format( LPCTSTR pFormat ) const;CString Format( UINT nFormatID ) const;Return ValueA CString that contains the formatted time.ParameterspFormatA formatting string similar to the printf formatting string. Formatting codes, preceded by a percent (%) sign, are replaced by the corresponding CTime component. Other characters in the formatting string are copied unchanged to the returned string. See the run-time functionstrftime for details. The value and meaning of the formatting codes for Format are listed below: %D Total days in this CTime
%H Hours in the current day
%M Minutes in the current hour
%S Seconds in the current minute
%% Percent sign
nFormatIDThe ID of the string that identifies this format. ResCall this member function to create a formatted representation of the date/time value. If the status of this CTime object is null, the return value is an empty string. If the status of CTime is invalid, the return value is an empty string.Example// example for CTime::Format and CTime::FormatGmt
CTime t( 1999, 3, 19, 22, 15, 0 );
// 10:15PM March 19, 1999
CString s = t.Format( "%A, %B %d, %Y" );
ASSERT( s == "Friday, March 19, 1999" );CTime Overview | Class Members | Hierarchy ChartSee Also CTime::FormatGmt
CTime time=CTime::GetCurrentTime();
time.GetYear();
time.GetMonth();
time.GetDay();
time.GetHour();
time.GetSecond();
time.GetMinute();
以上返回的都是int类型的。
然后你就知道如何使用了。