PDA

View Full Version : QTime and QDate from String



Eleasar
11th February 2014, 12:48
I have QString keeps dates like 2014-11-23 06:55:59
I want to parse this QString to QDate and QTime.

I've tried

QDate myDate;
myDate = QDate::fromString(qStr,"yyyy-MM-dd HH:mm:ss");

When i debug the code, i see QString value correctly, but mydate has no value. How can i fix it?

Lesiok
11th February 2014, 13:25
Because time is not a part of date ? Try this :

QDate myDate = QDateTime::fromString(qStr,"yyyy-MM-dd HH:mm:ss").date();

Eleasar
11th February 2014, 13:35
Done, Thank you ;)

mirzabey
23rd May 2015, 23:47
hi everyone,
i have been coding hotel management system and i would like to do something like this. in one lineedit it will be written check-in date which ı can do it and when i will write number of nights program will write automatically check-out date. i am waiting for your help.
thank you

ChrisW67
24th May 2015, 00:07
QDate::addDays()