Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDateTime:currentDateTime().toString(ISO:Date) does not display time zone
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 6.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • btseB Offline
    btseB Offline
    btse
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      http://doc.qt.io/qt-5/qdatetime.html#toString-1:
      "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."
      http://doc.qt.io/qt-5/qdatetime.html#currentDateTime:
      "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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved