I have some code that reads a datetime from a sqlite database, the datetime is returned as a string. when I try to convert it to a date using QDateTime::FromString it returns an invalid date. Below is the time as returned from the database and conversion. Why is this failing to parse?

// -this is the value returned from the DB currentServerTime=2012-01-17 19:20:27.0

QString format("yyyy/MM/dd hh:mm:ss");
QString qCurrentServerTime(currentServerTime);
now = QDateTime::fromString(qCurrentServerTime, format);

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top