How to add time stamp at the end of the file name?
-
I want to save files according to time, because of it i want to time stamp
QFile file("Infos/info.tm" );
How can i add time stamp at the end of the above file?
@firsnur96 said in How to add time stamp at the end of the file name?:
How can i add time stamp at the end of the above file?
Using https://doc.qt.io/qt-5/qstring.html#arg and https://doc.qt.io/qt-5/qtime.html#toString
-
I want to save files according to time, because of it i want to time stamp
QFile file("Infos/info.tm" );
How can i add time stamp at the end of the above file?
@firsnur96
Change the string to add whatever format you want from whatever time (current time) you want?
Though I actually suggest not adding it right at the end as that will destroy the.tm
file type suffix, so better:Infos/info_some_timestamp.tm
. -
@firsnur96
Change the string to add whatever format you want from whatever time (current time) you want?
Though I actually suggest not adding it right at the end as that will destroy the.tm
file type suffix, so better:Infos/info_some_timestamp.tm
.@JonB
I did it like that but it didnt work. I get this error messageQString::arg: Argument missing: Sakla/info, 11052021-113822
QIODevice::write (QFile, "Sakla/info"): device not openQDateTime now = QDateTime::currentDateTime(); QString timestamp = now.toString(QLatin1String("ddMMyyyy-hhmmss")); QString filename=QString::fromLatin1("Sakla/info").arg(timestamp); QFile file(filename);
-
@JonB
I did it like that but it didnt work. I get this error messageQString::arg: Argument missing: Sakla/info, 11052021-113822
QIODevice::write (QFile, "Sakla/info"): device not openQDateTime now = QDateTime::currentDateTime(); QString timestamp = now.toString(QLatin1String("ddMMyyyy-hhmmss")); QString filename=QString::fromLatin1("Sakla/info").arg(timestamp); QFile file(filename);
@firsnur96 said in How to add time stamp at the end of the file name?:
QString filename=QString::fromLatin1("Sakla/info%1.tm").arg(timestamp);
-
@firsnur96 said in How to add time stamp at the end of the file name?:
QString filename=QString::fromLatin1("Sakla/info%1.tm").arg(timestamp);