View Full Version : QTime and QDate from String

11th February 2014, 11: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?

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

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

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

23rd May 2015, 22: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

23rd May 2015, 23:07