Reputation: 380
so far im using:
QTime time = QTime::currentTime();
QString formattedTime = time.toString("hh:mm:ss");
QByteArray formattedTimeMsg = formattedTime.toLocal8Bit();
how do i change this to have date and time as "DD.MM.YYYY hh:mm:ss"?
Upvotes: 8
Views: 14544
Reputation: 4602
QDateTime date = QDateTime::currentDateTime();
QString formattedTime = date.toString("dd.MM.yyyy hh:mm:ss");
QByteArray formattedTimeMsg = formattedTime.toLocal8Bit();
qDebug() << "Date:"+formattedTime;
You can find more details here https://doc.qt.io/qt-5/qdatetime.html
Upvotes: 17