Date format to String



  • 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)



  • 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?



  • -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")


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.