1

I would like to use QDateTime to represent the value of 40 minutes less than the current time as a string.

QDateTime time = QDateTime::currentDateTime() - QDateTime::fromString(QDateTime::currentDateTime().toString("yy/MM/dd hh:40:00"), "yy/MM/dd hh:mm:ss");

I tried that. but, It's didn't working.

I want a string minus 40 minutes from the current time and date.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
a101a78
  • 27
  • 6

1 Answers1

4

QDateTime has an addSecs method. You can add -40 * 60 seconds to effectively subtract 40 minutes.

GolezTrol
  • 114,394
  • 18
  • 182
  • 210