QT获取当前系统时间并格式化用到类
#include <QDate>
#include <QTime>
#include <QDateTime>
获取日期时间并格式化
QDate::currentDate().toString("yyyy-MM-dd");
QTime::currentTime().toString("HH:mm:ss");
QTime::currentTime().toString("HH:mm:ss zzz");
QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss");
QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss:zzz")
若需要输出,则
QString time;
time=QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss:zzz");
qDebug()<<time;