QT 中 QDateTime::currentDateTime() 输出格式备查

基础

cpp 复制代码
QDateTime::currentDateTime() //当前的日期和时间。
QDateTime::toString() //以特定的格式输出时间,

格式

cpp 复制代码
yyyy: 年份(4位数)
MM: 月份(两位数,07表示七月)
dd: 日期(两位数,01表示第一天)
hh: 小时(两位数,24小时制)
mm: 分钟(两位数)
ss: 秒钟(两位数)

案列

cpp 复制代码
QString curTime = QDateTime::currentDateTime().toString("yyyy_MM_dd hh_mm_ss");

//yyyy-MM-dd hh:mm:ss
//输出效果类似于: "2023-11-30 07:51:44"。

效果

相关推荐
古德new18 小时前
鸿蒙PC迁移:Anki Qt 记忆卡片工具鸿蒙PC适配全记录
qt·华为·harmonyos
雪的季节20 小时前
Qt 进程间通信(IPC)全方案
qt
雪的季节21 小时前
Qt Graphs 2D+3D介绍
qt·3d
小鹏linux1 天前
鸿蒙PC迁移:TupiTube Desk Qt 2D 动画工作室鸿蒙PC适配全记录
qt·华为·harmonyos
鸽芷咕1 天前
鸿蒙PC迁移:LANDrop Qt 局域网传输工具鸿蒙PC适配全记录
qt·华为·harmonyos
Lhan.zzZ1 天前
Qt Quick 嵌套 Dialog 与 ComboBox 层级混乱问题解决
c++·qt
森G1 天前
67、Qt 多媒体框架概述---------多媒体
开发语言·qt
鸽芷咕1 天前
鸿蒙PC迁移:MoonPlayer Qt 视频播放器鸿蒙PC适配全记录
qt·音视频·harmonyos
小鹏linux1 天前
鸿蒙PC迁移:Phototonic Qt 图片查看器鸿蒙适配全记录:一次从 Widgets 桌面应用到 HAP 的迁移
qt·华为·harmonyos
knighthood20011 天前
鸿蒙PC迁移:KeePassXC Qt 密码管理器鸿蒙PC适配全记录
qt·华为·harmonyos