[SOLVED] Unable to convert string to int to perform MSecsSinceEpoch
General and Desktop
4
Posts
2
Posters
2.4k
Views
1
Watching
-
Hello people!
I'm trying to convert a string into a date time format in the following way
@
QDateTime timestamp;
timestamp.setMSecsSinceEpoch(1350977160000);
qDebug()<< timestamp.toString(Qt::SystemLocaleLongDate);
@This works well and gives me the correct output as Tuesday, 23 October, 2012 12:56:00 PM
However, when I store 1350977160000 into a QString and then try to convert it to int , it doesn't seem to give the correct output. Instead, I get Tuesday, 05 February, 2013 5:30:00 AM@
QDateTime timestamp;
QString s = "1350977160000";bool ok; quint64 dateTime = s.toLong(&ok,10); timestamp.setMSecsSinceEpoch(dateTime); qDebug()<< timestamp.toString(Qt::SystemLocaleLongDate);
@
Please help me. Where am I going wrong?
Thanks.