`
huozheleisi
  • 浏览: 1234394 次
文章分类
社区版块
存档分类
最新评论

CTime/COleDateTime::Format方法的使用

 
阅读更多

CTime/COleDateTime::Format方法的使用

CTime ct = CTime::GetCurrentTime();
CString str = ct.Format("%Y-%m_%d %H-%M-%S");
输出为:str="2006-04-23 15-21-30"
%a
Abbreviated weekday name
%A
Full weekday name
%b
Abbreviated month name
%B
Full month name
%c
Date and time representation appropriate for locale
%d
Day of month as decimal number (01 – 31)
%H
Hour in 24-hour format (00 – 23)
%I
Hour in 12-hour format (01 – 12)
%j
Day of year as decimal number (001 – 366)
%m
Month as decimal number (01 – 12)
%M
Minute as decimal number (00 – 59)
%p
Current locale's A.M./P.M. indicator for 12-hour clock
%S
Second as decimal number (00 – 59)
%U
Week of year as decimal number, with Sunday as first day of week (00 – 53)
%w
Weekday as decimal number (0 – 6; Sunday is 0)
%W
Week of year as decimal number, with Monday as first day of week (00 – 53)
%x
Date representation for current locale
%X
Time representation for current locale
%y
Year without century, as decimal number (00 – 99)
%Y
Year with century, as decimal number
%z, %Z
Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown
%%
Percent sign
// 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" );
ATLASSERT( s == "Friday, March 19, 1999" );
分享到:
评论

相关推荐

    CTime::Format参数使用说明

    十分详细的列举了CTime::Format的参数使用说明,比msdn详细点,希望对初学者有帮助

    linux 系统编程 网络编程 源码

    asctime.c ctime.c gettimeofday.c strftime.c timea.c ./udp: client client_echo client_loop reliable_udp server_echo.c server_loop.c udp_server client1 client_echo.c client_loop.c server server_hello ...

    自己写的CTime类

    一个自己写的类CTime类,主要实现的功能是: 1、可以以字符串的形式为类实例赋值; 2、重载了“+”操作符,可以对当前实例进行加减操作(单位为秒),操作后得到正确的绝对时间。

    Time基于MFC调用系统时间

    CTime time = CTime::GetCurrentTime(); //得到系统时间 m_strTime = time.Format("%Y-%m-%d %H:%M:%S"); SetTimer(1,1000,NULL); //设置1s的定时器 UpdateData(FALSE); GetDlgItem(IDC_EDIT_WINTIME)->...

    VC++常用函数

    省宽度,使用此值将为时间的显示预留空间)。注 2)在MainFrm.cpp中indicators声明处添加ID_INDICATOR_CLOCK,代 码如下:  这一步中ID_INDICATOR_CLOCK的插入位置将影响时间窗格在状态栏中 的显示位置。  3)安装...

    super_CTime CTime的各种转换子程序库。

    super_CTime CTime的各种转换子程序库。和字符串的转换、和数字的转换等等 std::string getDateString(bool fgf);//获得表示当前日期的字符串,fgf表示是否需要分隔符 std::string getTimeString(bool fgf);//...

    asp无限分类使用简单功能强大生成HTML自定义表单

    说明:文档显示页标签 可以显示文档的各个字段值,如:title,hits,content,ctime等 #{Prenext/}:显示上一篇、下一篇 8、#{pl }***{/} 9、#{book }***{/} 更多、更详细的标签自己在使用中来发现哦!~~~

    ListView 应用示例

    //CTime; SYSTEMTIME sysTime; GetLocalTime(&sysTime); CString strTime; strTime.Format(_T("%04d-%02d-%02d %02d:%02d:%02d"), sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime...

    Python中的ctime()方法使用教程

    ctime()方法转换,因为历元到表示本地时间的字符串表示以秒为单位的时间。如果不设置秒时或None,所...下面的例子显示了ctime()方法的使用。 #!/usr/bin/python import time print "time.ctime() : %s" % time.ctime()

    C++-写一个聊天机器人.pdf

    #include <ctime> int main() { std::string Response[] = { "I HEARD YOU!", "SO, YOU ARE TALKING TO ME.", "CONTINUE, I'M LISTENING.", "VERY INTERESTING CONVERSATION.", "TELL ME MORE..." }; srand(...

    c++ 时间 stl ctime使用demo

    c++ 时间 stl ctime使用demo

    CTime

    CTime:VC++编写定时器的程序,功能:一个在edit中显示为当前时间,另外两个显示为定时器的功能

    能在VB实现支干时间组件

    最为关键的是本组件上多了干支年、干支月、干支日、干支时这是目前第一个能在VB上使用的干支算法的组件 控件版本号:1.0 在本站中所属的类别:时间控件 使用平台( unix, windows 或其它):windows 发布日期:...

    ctime

    这是一个用来计算程序运行时间的小程序,使用方法很简单 ctime 程序 [程序参数] 结果说明: Total 表示整个程序运行时间 Kernel 在内核模式下运行时间 User 在用户模式下运行时间 欢迎来信提出建议和意见! ...

    ctime:一个Python程序,用于在树莓派上用残障人士儿子Chris娱乐(带有触摸屏显示器)

    码头工人有一个Dockerfile,像这样构建: docker build -t local:ctime docker并像这样运行它(假设您在docker目录中): docker run -d -v /tmp/.X11-unix:/tmp/.X11-unix -v ${PWD}/..:/opt/ctime --privileged ...

    C++实践Time类中的运算符重载参考方法

    class CTime { private: unsigned short int hour; // 时 unsigned short int minute; // 分 unsigned short int second; // 秒 public: CTime(int h=0,int m=0,int s=0); void setTime(int h,int m,int s); ...

    VC++ 获取系统时间的方法汇总

    1.使用CTime类(获取系统当前时间,精确到秒) CString str; //获取系统时间 CTime tm; tm=CTime::GetCurrentTime();//获取系统日期 str=tm.Format(现在时间是%Y年%m月%d日 %X); MessageBox(str,NULL,MB_OK); a,...

    MFC获取日期和计时器1

    // 用于将CTime对象格式化为字符 // 获取当前时间并保存到curTime CTime curTime = CTime::GetCurrentTime

    php 时间美化 友好时间函数

    //sTime=源时间,cTime=当前时间,dTime=时间差 $cTime = time(); $dTime = $cTime - $sTime; $dDay = intval(date("z",$cTime)) - intval(date("z",$sTime)); //$dDay = intval($dTime/3600/24); $dYear = ...

    VC 获取当前的日期、时间并格式化输出.rar

     m_time=CTime::GetCurrentTime();//获取当前时间日期  m_strDate=m_time.Format("%x");//格式化日期  m_strTime=m_time.Format("%X");//格式化时间  m_strDateTime=m_time.Format("%Y-%m-%d %H:%M:%S 第%W周...

Global site tag (gtag.js) - Google Analytics