到目前为止,我正在使用:
QTime time = QTime::currentTime();
QString formattedTime = time.toString("hh:mm:ss");
QByteArray formattedTimeMsg = formattedTime.toLocal8Bit();
Run Code Online (Sandbox Code Playgroud)
我如何将其更改为“DD.MM.YYYY hh:mm:ss”的日期和时间?
QDateTime date = QDateTime::currentDateTime();
QString formattedTime = date.toString("dd.MM.yyyy hh:mm:ss");
QByteArray formattedTimeMsg = formattedTime.toLocal8Bit();
qDebug() << "Date:"+formattedTime;
Run Code Online (Sandbox Code Playgroud)
您可以在此处找到更多详细信息https://doc.qt.io/qt-5/qdatetime.html