Important: Please read the Qt Code of Conduct -

[solved] Return time in UTC with Qt 4.7

  • Hello
    How can I return the current time in UTC with Qt 4.7? The following code:


    causes the following error:

    error: no matching function for call to 'QTime::currentTime(Qt::TimeSpec)'
    qt-4.7.3/include/QtCore/qdatetime.h:183: note: candidates are: static QTime QTime::currentTime()


  • @QDateTime::currentDateTimeUtc().time()@

  • To cite the docs of [[Doc:QTime]]:

    bq. Unlike QDateTime, QTime knows nothing about time zones or daylight savings time (DST).

    So, I would suggest to use "QDateTime::currentDateTimeUtc() ":/doc/qt-4.8/qdatetime.html#currentDateTimeUtc instead.

  • Thank you!

    • Richard

Log in to reply