I've got a QString that contains a date in the following format:
2014-03-18 09:30:36
How can i format it to: HH:mm?
You can use QDateTime::fromString and QDateTime::toString methods:
QString dateStr = "2014-03-18 09:30:36";
QString fmt = "yyyy-MM-dd hh:mm:ss";
QDateTime dt = QDateTime::fromString(dateStr, fmt);
QString timeStr = dt.toString("hh:mm");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With