CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

如何将CTime 类型转换为CString

楼主gflpower(燕赤侠)2003-12-01 08:45:52 在 VC/MFC / 基础类 提问

如何将CTime   类型转换为CString 问题点数:0、回复次数:10Top

1 楼dzqsuper(数风流人物-还看打倒日本猪的人(抵制日货))回复于 2003-12-01 08:49:46 得分 0

加入收藏夹Top

2 楼zfive5(醉马不肖)回复于 2003-12-01 08:54:00 得分 0

CTime::FormatSee   Also  
  CTime   Overview   |   Class   Members   |   Hierarchy   Chart   |   CTime::FormatGmt  
  Call   this   member   function   to   create   a   formatted   representation   of   the   date/time   value.  
   
  CString   Format(  
        LPCTSTR   pszFormat    
  )   const;  
  CString   Format(  
        UINT   nFormatID    
  )   const;  
  Parameters  
  pszFormat    
  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   function   strftime   for   a   list   of   formatting   codes.    
  nFormatID    
  The   ID   of   the   string   that   identifies   this   format.    
  Return   Value  
  A   CString   that   contains   the   formatted   time.  
   
  Remarks  
  If   the   status   of   this   CTime   object   is   null,   the   return   value   is   an   empty   string.  
   
  Example  
  //   Example   for   CTime::Format   and   CTime::FormatGmt  
  CTime   t(   1999,   3,   19,   22,   15,   0   );    
  //   10:15   PM   March   19,   1999  
  CString   s   =   t.Format(   "%A,   %B   %d,   %Y"   );  
  ASSERT(   s   ==   "Friday,   March   19,   1999"   );  
  Top

3 楼arvid_gs(west)回复于 2003-12-01 08:56:52 得分 0

CTime   t(   1999,   3,   19,   22,   15,   0   );    
  //   10:15   PM   March   19,   1999  
  CString   s   =   t.Format(   "%A,   %B   %d,   %Y"   );  
  ASSERT(   s   ==   "Friday,   March   19,   1999"   );Top

4 楼zhansg(阿土)回复于 2003-12-01 09:02:11 得分 0

CTime   t;  
  CString   s;  
   
  t   =   CTime::GetCurrentTime();  
  s   =   t.Format("%A,   %B   %d,   %Y");  
  s   =   t.Format("%Y/%m/%d");  
  s   =   t.Format("%H:%M:%S");  
  //....Top

5 楼Rayanywhere()回复于 2003-12-01 09:05:31 得分 0

用一个字符串变量格式化不就行了Top

6 楼liken218(想走走不了!)回复于 2003-12-01 09:06:52 得分 0

如“2003-01-12   14:15:16"  
  CTime   tm=CTime::GetCurrentTime();  
  CString   str=tm.Format("%Y-%m-%d   %H:%M:%S");Top

7 楼gflpower(燕赤侠)回复于 2003-12-01 09:22:28 得分 0

 
  这是帮助中的内容,没有用这个问题已经解决了谢谢  
  Top

8 楼gflpower(燕赤侠)回复于 2003-12-01 09:23:04 得分 0

回得好  
  Top

9 楼gflpower(燕赤侠)回复于 2003-12-01 09:26:22 得分 0

谢谢各位兄台  
   
  Top

10 楼dzqsuper(数风流人物-还看打倒日本猪的人(抵制日货))回复于 2004-02-12 20:36:45 得分 0

那就得结贴呀Top

相关问题

  • 如何把CString转换为CTime类型?
  • 如何把CString类型转换为CTime类型?
  • 请教将CString类型转换为CTime类型的方法??
  • CString类型转换
  • CString t.format("2005-8-25 14:00:35")如何将他转换为CTime类型?
  • 数据库中的类型(CString和 CTime)和VC中的类型转换?
  • 类型转换 unsigned int <==>CString
  • CString 的类型转换?
  • 很笨的问题,如何将CTime的类型转换成CString的类型,用CTime::Format函数吗?
  • CTime 怎么转换成 CString?

关键词

  • 转换
  • ctime
  • nformatid
  • format
  • 类型转换
  • cstring
  • member
  • example
  • const
  • codes

得分解答快速导航

  • 帖主:gflpower

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo