1

i'm trying to use QDateTime for one of my project. But everything is going wrong when i use QDateTime::currentTime().msecsTo() ....

QString FORMAT = "d/MM/yy hh:mm:ss";
QDateTime at = QDateTime::fromString("30/06/15 12:00:00", FORMAT);
qDebug() << QDateTime::currentDateTime().msecsTo(at);  //Current DateTIme : 30/06/15 11:51:00 OUTPUT : -3155755905986

And the out put gives me : -3155755905986 Which doesn't make any sens ...

Any idea ? Thank you.

2 Answers2

2

Actually everything is ok for qt this value is 100 years earlier - 30/06/1915 https://www.unitjuggler.com/convert-time-from-ms-to-yr-365.html?val=3155756569078

QDate - wrong year

I suggest using format "dd/MM/yyyy hh:mm:ss"

Community
  • 1
  • 1
Robert Wadowski
  • 1,407
  • 1
  • 11
  • 14
0

Qt doc says if the other datetime is earlier than this datetime, the value returned is negative. I think it is expected behaviour.

Vedanshu
  • 2,230
  • 23
  • 33