QDateTime currentDateTime = QDateTime::currentDateTime(); QDateTime updatedDateTime = currentDateTime.addSecs(60); // Add 60 seconds to current date and time
QDateTime startTime(QDate(2022, 10, 1), QTime(12, 0)); QDateTime endTime = startTime.addSecs(3600); // Add 1 hour to start time to get end timeIn the above examples, we have used the QDateTime class to create objects for current date and time (in Example 1) and a specified date and time (in Example 2). We have then used the addSecs() function to add a specified number of seconds to these objects and store the updated date/time in a new QDateTime object. The package/library that contains the QDateTime class is the Qt library for C++.