Important: Please read the Qt Code of Conduct -

QDateTime:currentDateTime().toString(ISO:Date) does not display time zone

  • Using Qt5.11.2:
    QDateTime::currentDateTime().toString(Qt::ISODate) does not include the timezone.
    The above for me produces 2019-02-01T10:49:13 without the expected offset from UTC at the end.

    Is there a correct way to get this string?

  • Qt Champions 2019
    "If the format is Qt::ISODate, the string format corresponds to the ISO 8601 extended specification for representations of dates and times, taking the form yyyy-MM-ddTHH:mm:ss[Z|[+|-]HH:mm], depending on the timeSpec() of the QDateTime. If the timeSpec() is Qt::UTC, Z will be appended to the string; if the timeSpec() is Qt::OffsetFromUTC, the offset in hours and minutes from UTC will be appended to the string."
    "Returns the current datetime, as reported by the system clock, in the local time zone."

    So I don't see why the timezone should be appended.

Log in to reply