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. Date format to String
Qt 6.11 is out! See what's new in the release blog

Date format to String

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.0k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    maniek1310
    wrote on last edited by
    #1

    Hi,

    I have a variable QString date, and now I do not know how to convert that was normal date.

    QString (20140131174428.000000+060) to QString(2014-01-31 17:44:28)

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      QDateTime::fromString("20140131174428.000000+060","yyyyMMddhhmmss.zzz000+060").toString("yyyy-MM-dd HH:mm:ss");

      The microseconds and the timezone GMT+1, couldn't fix easy, maybe they're immaterial?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maniek1310
        wrote on last edited by
        #3

        -I did as you wrote :
        @QDateTime::fromString(system_instalation, "yyyyMMddhhmmss.zzz000+060").toString("yyyy-MM-dd HH:mm:ss");

        ui->system_instalation_2->setText(system_instalation);@
        

        but during the compilation of such errors pops :
        @E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: ostrzeżenie: C4003: not enough actual parameters for macro 'min'
        E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: błąd: C2589: '(' : illegal token on right side of '::'
        E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: błąd: C2059: syntax error : '::'
        E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: ostrzeżenie: C4003: not enough actual parameters for macro 'min'
        E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: błąd: C2589: '(' : illegal token on right side of '::'
        E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: błąd: C2059: syntax error : '::'
        E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: ostrzeżenie: C4003: not enough actual parameters for macro 'min'
        E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: błąd: C2589: '(' : illegal token on right side of '::'
        E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: błąd: C2059: syntax error : '::'
        E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: ostrzeżenie: C4003: not enough actual parameters for macro 'min'
        E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: błąd: C2589: '(' : illegal token on right side of '::'
        E:\Qt_5.3\5.3\msvc2010_opengl\include\QtCore\qdatetime.h:122: błąd: C2059: syntax error : '::'@

        Ps. Already working. It was enough to add to the header file # define NOMINMAX against libraries that belong to the Visual C + + example ("windows.h")

        1 Reply Last reply
        0

        • Login

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