QTimeDate::currentDateTime 未按预期工作

QTimeDate::currentDateTime not working as expected

我正在尝试将 QDateTime 用于我的一个项目。但是当我使用 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

输出结果是:-3155755905986 这没有任何意义...

有什么想法吗? 谢谢你。

实际上对于 qt 来说一切正常,这个值早了 100 年 - 1915 年 6 月 30 日 https://www.unitjuggler.com/convert-time-from-ms-to-yr-365.html?val=3155756569078

QDate - wrong year

我建议使用格式 "dd/MM/yyyy hh:mm:ss"

Qt 文档说 if the other datetime is earlier than this datetime, the value returned is negative。我认为这是预期的行为。