How to add days,hours and minutes to QDataTime

  • Hi I am trying to change my data adding 2 days and 300 seconds but my code dont work do you have any ideas how to resolve it thanks.
    QString format = "yyyy-MM-dd HH:mm";
    QDateTime a1 = QDateTime::fromString("2017-11-19 12:49", format);//час в дорозі

    // a2.addSecs(time[time.size()-i].toInt()+500);
     QString s = a1.toString(format);
    // QString s1 = a2.toString(format);

    //your code here

  • @mark_ua_1999


    Look at the documentation. These are functions returning a new QDateTime, they do not change the a1 value.

     a1 = a1.addDays(2);
     a1 = a1.addSecs(300);

  • @JNBarchan thanks for your help

Log in to reply

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