Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用 QDateTime 将比当前时间少 40 分钟的值表示为字符串。
QDateTime time = QDateTime::currentDateTime() - QDateTime::fromString(QDateTime::currentDateTime().toString("yy/MM/dd hh:40:00"), "yy/MM/dd hh:mm:ss");
我试过了。但是,它没有工作。
我想要一个从当前时间和日期减去 40 分钟的字符串。
QDateTime 有一个 addSecs 方法。您可以添加-40 * 60秒数来有效地减去 40 分钟。
-40 * 60