Use the toString function. The format parameter determines the format of the result string.
For example, the following code will return only seconds and milliseconds.
QDateTime t = QDateTime::currentDateTime (); QString s = t.toString("ss:zzz");
PS. You should consider porting code to Qt4
source share