QString QDateTime::toString ( const QString & format ) const
来源:互联网 发布:淘宝质量问题退货认定 编辑:程序博客网 时间:2024/06/02 05:30
例如:QDateTime::currentDateTime().toString("yyyy年MM月dd日 hh:mm:ss"); //输出为“2011年10月15日 18:22:13”
具体的格式设置Qt的文档中写得比较全:
These expressions may be used for the date:
d
the day as number without a leading zero (1 to 31)
dd
the day as number with a leading zero (01 to 31)
ddd
the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses QDate::shortDayName().
dddd
the long localized day name (e.g. 'Monday' to 'Qt::Sunday'). Uses QDate::longDayName().
M
the month as number without a leading zero (1-12)
MM
the month as number with a leading zero (01-12)
MMM
the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses QDate::shortMonthName().
MMMM
the long localized month name (e.g. 'January' to 'December'). Uses QDate::longMonthName().
yy
the year as two digit number (00-99)
yyyy
the year as four digit number
These expressions may be used for the time:
h
the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
hh
the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
m
the minute without a leading zero (0 to 59)
mm
the minute with a leading zero (00 to 59)
s
the second without a leading zero (0 to 59)
ss
the second with a leading zero (00 to 59)
z
the milliseconds without leading zeroes (0 to 999)
zzz
the milliseconds with leading zeroes (000 to 999)
AP
use AM/PM display. AP will be replaced by either "AM" or "PM".
ap
use am/pm display. ap will be replaced by either "am" or "pm".
All other input characters will be ignored. Any sequence of characters that are enclosed in singlequotes will be treated as text and not be used as an expression. Two consecutive singlequotes ("''") are replaced by a singlequote in the output.
Example format strings (assumed that the QDateTime is 21 May 2001 14:13:09):
dd.MM.yyyy
21.05.2001
ddd MMMM d yy
Tue May 21 01
hh:mm:ss.zzz
14:13:09.042
h:m:s ap
2:13:9 pm
If the datetime is invalid, an empty string will be returned.
- QString QDateTime::toString ( const QString & format ) const
- QString QDate::toString ( const QString & format ) const
- int QString::size () const
- "QString" to "const char*"
- QString & QString::sprintf(const char * cformat, ...)应用
- const char* 转QString错误
- QDateTime转换为QString
- QT类型转换 QString转const char*,QString转u_short
- QString类型转化成const char *类型
- Qt QString类型 转换为 const char*
- QString类型转化成const char *类型
- 错误记录:QString转const char* 问题
- 'QString::QString(const char*)' is qstring.h private的原因和解决
- QString和QDateTime之间的相互转换
- QString和QDateTime之间的相互转换
- QString和QDateTime之间的相互转换
- QDateTime和QString的转换问题
- QString和QDateTime之间的相互转换
- C#使用String.Format()方法时,出现异常"输入的字符串格式有误"的解决方法
- C++打开文件的方式
- 使用matlab引擎的应用程序正常运行
- 深入理解子类继承父类中的成员变量问题
- Android 蓝牙编程学习一基本操作
- QString QDateTime::toString ( const QString & format ) const
- UltraEdit使用技巧
- Java nio 学习笔记(一) Buffer(缓冲区)与Channel(通道)的相关知识
- 默认构造函数的访问权限
- Java nio 学习笔记(二) Charset(字符集)与Selector(异步IO)的知识
- uboot makefile分析
- 神奇的图像处理算法
- Java nio 学习笔记(三)
- Javascript简单跑马灯