Solved Invalid DateTime Error
-
Hi ,
I am trying to convert a string to qDateTime. But every time , i'm getting Invalid() datetime errror.Below is my code snippet.Please someone let me know how to fix it
QString lastdate = "12-06-2019 1:30"
QString date = lastdate ;
QString format = "dd-MM-yyyy HH:mm";
qDebug()<<"date:"<<lastdate;
qDebug()<<"format:"<<format;
QDateTime dateTime = QDateTime::fromString(date, format);
bool isItValid = dateTime.isValid();Thank you
-
HH:mm
expects a leading 0 for the hours.
12-06-2019 1:30
clearly has no leading 0 -> Format error -
@J.Hilk
Thank you so much . It solved the problem :)