mkallay
17th June 2016, 23:15
Fore the following code snippet
quint64 t = 1464808943000;
QDateTime dt;
dt.fromMSecsSinceEpoch(t);
if (dt.isValid())
cout << "Valid" << endl;
else
cout << "Not valid" << endl;
QString format = QString("yyyy.MM.dd.hh.mm.ss");
QString timeStamp = dt.toString(format);
cout << timeStamp.toStdString() << endl;
The output is
Not Valid,
(empty string)
I am convinced that the number is valid. Entering it in http://www.epochconverter.com/ generates a valid date-time Wed, 01 Jun 2016 19:22:23 GMT.
Using Qt 4.8 on Wincows 8, compiling with Visual Studio 2010.
What am I doing wrong?
Michael
quint64 t = 1464808943000;
QDateTime dt;
dt.fromMSecsSinceEpoch(t);
if (dt.isValid())
cout << "Valid" << endl;
else
cout << "Not valid" << endl;
QString format = QString("yyyy.MM.dd.hh.mm.ss");
QString timeStamp = dt.toString(format);
cout << timeStamp.toStdString() << endl;
The output is
Not Valid,
(empty string)
I am convinced that the number is valid. Entering it in http://www.epochconverter.com/ generates a valid date-time Wed, 01 Jun 2016 19:22:23 GMT.
Using Qt 4.8 on Wincows 8, compiling with Visual Studio 2010.
What am I doing wrong?
Michael