Getting milliseconds accuracy current time in Qt

HMD picture HMD · Jul 30, 2015 · Viewed 13.9k times · Source

Qt documentation about QTime::currentTime() says :

Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.

But is there any way to get this time with milliseconds accuracy in windows 7?

Answer

Ritchy MFinda picture Ritchy MFinda · Jun 12, 2018

You can use QDateTime class and convert the current time with the appropriate format:

QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss,zzz")

where 'z' corresponds to miliseconds accuracy.