VC++ CTime Format 详解
参考链接:
CTime/COleDateTime::Format方法的使用
http://stat.ethz.ch/R-manual/R-devel/library/base/html/strptime.html
http://www.geezer.org/sw/mvform/doc/strftime.txt
CTime::Format主要用来格式化日期和时间。
举例:
CTime ctNow=CTime::GetCurrentTime();
CString strTime1 = ctNow.Format(_T("%Y年%m月%d日")); // 2014年05月27日
CString strTime2 = ctNow.Format(_T("%Y-%m-%d %H:%M:%S")); // 2014-05-27 14:24:45
CString strTime3 = ctNow.Format(_T("%Y-%#m-%#d %H:%M:%S")); // 2014-5-27 14:24:45
CString strTime4 = ctNow.Format(_T("%c")); // 05/27/14 14:24:45
格式化的参数详细列举如下:
Formats |
Description |
Memo/Example |
%a |
abbreviated weekday name |
星期的缩写 |
%A |
full weekday name |
完整的星期名 |
%b |
abbreviated month name |
月份的缩写 |
%B |
full month name |
完整的月份名 |
%c |
locale's date and time representation |
当前区域(设置)的日期和时间, 如,05/27/14 13:42:43 |
%d |
the day of the month as a decimal number (01-31) |
日 如,27 |
%H |
the hour (24-hour clock) as a decimal number(00-23) |
24小时制的小时(00-23) |
%I |
the hour (12-hour clock) as a decimal number(01-12) |
12小时制的小时(00-12) |
%j |
the day of the year as a decimal number (001-366). |
一年的第几天 如,147 |
%m |
the month as a decimal number (01-12). |
月份(00-12) 如,05 |
%M |
the minute as a decimal number (00-59). |
分钟(00-59) |
%p |
locale's equivalent of ``AM'' (ante meridiem) or ``PM'' (post meridiem) as appropriate |
PM 或者 AM |
%S |
the second as a decimal number (00-60) |
秒钟(00-59) |
%U |
the week number of the year (the first Sunday as the first day of week 1) as a decimal number (00-53). |
一年的第几周(周日是第一周的第一天) |
%w |
the weekday (Sunday as the first day of the week) as a decimal number (0-6). |
工作日(0-6,周日是一周的第一天) |
%W |
the week number of the year (the first Monday as the first day of week 1) as a decimal number (00-53). |
一年的第几周(周一是第一周的第一天) |
%x |
locale's date representation |
当地区域的日期 如,05/27/2014 |
%X |
locale's time representation |
当地区域的时间 如,13:54:12 |
%y |
the year without century as a decimal number (00-99). |
年(00-99) 如, 14 |
%Y |
the year with century as a decimal number. |
年 如,2014 |
%Z |
the time zone name |
时区名称 如,China Standard Time |
月份的全称和缩写: 星期的全称和缩写:
|
Full Month Name |
Abbreviated Month Name |
|
January |
Jan |
|
February |
Feb |
|
March |
Mar |
|
April |
Apr |
|
May |
May |
|
June |
Jun |
|
July |
Jul |
|
August |
Aug |
|
September |
Sep |
|
October |
Oct |
|
November |
Nov |
|
December |
Dec |
|
Full Weekday Name |
Abbreviated Weekday Name |
|
Sunday |
Sun |
|
Monday |
Mon |
|
Tuesday |
Tue |
|
Wednesday |
Wed |
|
Thursday |
Thu |
|
Friday |
Fri |
|
Saturday |
Sat |
VC++ CTime Format 详解的更多相关文章
- 【转】Java魔法堂:String.format详解
Java魔法堂:String.format详解 目录 一.前言 二.重载方法 三.占位符 四.对字符.字符串进行格式化 五.对整数进行格式化 六. ...
- 【转】declare-styleable的使用(自定义控件) 以及declare-styleable中format详解
原文网址:http://www.cnblogs.com/622698abc/p/3348692.html declare-styleable是给自定义控件添加自定义属性用的 1.首先,先写attrs. ...
- 自定义控件的自定义的属性attrs.xml下的declare-styleable中format详解
最近在摸索自定义控件,查找到一些自定义属性的一些资料,解决转载记载下来:看了此详解才方便理解! 我们在做项目的时候,由于android自带的属性不能满足需求,android提供了自定义属性的方法,其中 ...
- VC++的文件格式详解
.APS:存放二进制资源的中间文件,VC把当前资源文件转换成二进制格式,并存放在APS文件中,以加快资源装载速度.资源辅助文件. .BMP:位图资源文件. .BSC:浏览信息文件,由浏览信息维护工具( ...
- String.format详解(转)
一.前言 String.format 作为文本处理工具,为我们提供强大而丰富的字符串格式化功能,为了不止步于简单调用 String.format("Hello %s", " ...
- Java魔法堂:String.format详解
目录 一.前言 二.重载方法 三.占位符 四.对字符.字符串进行格式化 五.对整数进行格式化 六.对浮点数进行格式化 七.对日期时间进行格式化 ...
- 【转】String.format详解
一.前言 String.format 作为文本处理工具,为我们提供强大而丰富的字符串格式化功能,为了不止步于简单调用 String.format("Hello %s", " ...
- VC++制作DLL详解
1. DLL的基本概念 应用程序(exe)要引用目标代码(.obj)外部的函数时,有两种实现途径——静态链接和动态链接. 1. 静态链接 链接程序搜索对应的库文件(.lib),然后将这个对 ...
- java String.Format详解
JDK1.5中,String类新增了一个很有用的静态方法String.format(): format(Locale l, String format, Object... args) 使用指定的语言 ...
随机推荐
- java 学习基础学习单词及java关键词
在JAVA学习中我们难免会犯一些逻辑错误,语法错误,和一些运行错误,对于英语不好的人,就的记下下面的2常用单词,有助于我们提高在使用软件编写代码的速度和代码调试,能更便捷的找出错误,知道1中的保溜关键 ...
- js中substr,substring,indexOf,lastIndexOf,split用法
1.substr substr(start,length)表示从start位置开始,截取length长度的字符串. var src="images/off_1.png"; aler ...
- [Bootstrap] 4. Typogrphy
What is Typography When we talk about typography, it's a big subject! Which of the following fall un ...
- android开发 Fragment嵌套调用常见错误
在activity中有时须要嵌套调用fragment,但嵌套调用往往带来视图的显示与预期的不一样或是fragment的切换有问题.在使用时要注意几点: 1.fragment中嵌套fragment,子f ...
- css Hack,用IE11模拟测试的,条件注释要找真IE去测,模拟的无效
<!DOCTYPE html> <!--[if lt IE 7 ]> <html class="ie6 ie"> <![endif]--& ...
- Android屏幕分辨率详解(VGA、HVGA、QVGA、WVGA、WQVGA)
这些术语都是指屏幕的分辨率. VGA:Video Graphics Array,即:显示绘图矩阵,相当于640×480 像素: HVGA:Half-size VGA:即:VGA的一半,分辨率为480× ...
- rem移动端适配
rem作为一个低调的长度单位,由于手机端网页的兴起,在屏幕适配中得到重用.使用 rem 前端开发者可以很方便的在各种屏幕尺寸下,通过等比缩放的方式达到设计图要求的效果. rem 的官方定义『The f ...
- Java项目打包在CMD或者Linux下运行
Java项目打包在CMD或者Linux下运行 1.在CMD下运行 在eclipse中将项目export成jar包,然后用压缩软件解压
- spring整合quartz实现定时任务
需求:spring+mybatis框架已经搭建好,需要实现一个定时任务. 一:导出相应的jar包 quartz-all-1.6.5.jar获取quartz-alll-1.6.6.jar spring- ...
- Java中处理Linux信号量
为了防止无良网站的爬虫抓取文章,特此标识,转载请注明文章出处.LaplaceDemon/ShiJiaqi. http://www.cnblogs.com/shijiaqi1066/p/5976361. ...