How to add days,hours and minutes to QDataTime
-
wrote on 18 Nov 2017, 21:00 last edited by mark_ua_1999
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);//час в дорозіa1.addDays(2); a1.addSecs(300); // a2.addSecs(time[time.size()-i].toInt()+500); QString s = a1.toString(format); // QString s1 = a2.toString(format); ui->textBrowser->append(s);```
//your code here
-
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);//час в дорозіa1.addDays(2); a1.addSecs(300); // a2.addSecs(time[time.size()-i].toInt()+500); QString s = a1.toString(format); // QString s1 = a2.toString(format); ui->textBrowser->append(s);```
//your code here
wrote on 18 Nov 2017, 21:06 last edited bya1.addDays(2); a1.addSecs(300);
Look at the documentation. These are functions returning a new
QDateTime
, they do not change thea1
value.a1 = a1.addDays(2); a1 = a1.addSecs(300);
-
a1.addDays(2); a1.addSecs(300);
Look at the documentation. These are functions returning a new
QDateTime
, they do not change thea1
value.a1 = a1.addDays(2); a1 = a1.addSecs(300);
wrote on 18 Nov 2017, 21:20 last edited by@JNBarchan thanks for your help
1/3