About using QDateTime::fromString
-
I wanna translate time string from sqlite to QDateTime , but It seamed failed , here's the code :
@QDateTime date = QDateTime::fromString( "2013-1-12 14:53:42" , "yyyy-MM-dd hh:mm:ss" );
QString strDate,strTime;
do
{
strDate = date.date().toString();//empty
strTime = date.time().toString();//empty
} while (false);
@what's wrong?
-
From what I understood, you are trying to retrieve a string from the database and convert it to QDateTime format. Then, why you are converting it back to a string to check for it's emptiness?
Even if you must do that, you can simply use @strDate = date.toString("yyyy-MM-dd"); //empty@and @strTime = date.toString("hh:mm:ss");//empty@
-
has fixed , that's should be follow code:
@
QDateTime date = QDateTime::fromString( "2013-1-12 14:53:42" , "yyyy-M-d h:m:s" );
QString strDate,strTime;
do
{
strDate = date.date().toString();//empty
strTime = date.time().toString();//empty
} while (false);
@