📄 subject_17398.htm
字号:
<p>
序号:17398 发表者:不见天日 发表日期:2002-10-11 09:59:40
<br>主题:请问如何将ctime类的结果转化为字符串?
<br>内容:在一 Edit Box 中用CTime取出了日期,先在想把结果转化为CString,应该如何做呢?<BR><BR>我真是绝对菜鸟<BR>:(
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:黄飚 回复日期:2002-10-11 10:04:20
<br>内容:t.Format("%Y%M%D");<BR>CTime::Format <BR>CString Format( LPCTSTR pFormat ) const;<BR><BR>CString Format( UINT nFormatID ) const;<BR><BR>Return Value<BR><BR>A CString that contains the formatted time.<BR><BR>Parameters<BR><BR>pFormat<BR><BR>A 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: <BR><BR>%D Total days in this CTime<BR><BR><BR>%H Hours in the current day<BR><BR><BR>%M Minutes in the current hour<BR><BR><BR>%S Seconds in the current minute<BR><BR><BR>%% Percent sign <BR>nFormatID<BR><BR>The ID of the string that identifies this format. <BR><BR>Remarks<BR><BR>Call 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.<BR><BR>Example<BR><BR>// example for CTime::Format and CTime::FormatGmt<BR>CTime t( 1999, 3, 19, 22, 15, 0 ); <BR>// 10:15PM March 19, 1999<BR>CString s = t.Format( "%A, %B %d, %Y" );<BR>ASSERT( s == "Friday, March 19, 1999" );<BR><BR>CTime Overview | Class Members | Hierarchy Chart<BR><BR>See Also CTime::FormatGmt<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:子龙 回复日期:2002-10-11 10:04:23
<br>内容:CTime::Format 就可以
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:不见天日 回复日期:2002-10-11 10:22:37
<br>内容:谢谢楼上两位..还是我msdn看的不仔细。<BR>:)<BR>没看format的例子..<BR>谢谢了..<BR>分就给我的本家吧.
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -