Converting Date Format
-
@Vineela
As @jsulm has just stated, you now have an issue about your date output format not the input you converted from. Look through the documentation of http://doc.qt.io/qt-5/qdate.html#toString, i.e.toString()
notfromString()
. -
Converting QString date format from "yyyy-MM-dd" to "dd-MM-yyyy"
this is my QString
QString dd = "2018-08-01";QDate da=QDate::fromString(dd,"dd-MM-yyyy");
well this line gives error saying "QDate(Invalid)"
so how can i change my format???@Vineela said in Converting Date Format:
QDate da=QDate::fromString(dd,"dd-MM-yyyy");
Shouldn't it be
QDate da=QDate::fromString(dd,"yyyy-MM-dd");
?
Your string is "2018-08-01" and not "01-08-2018"... -
@Vineela said in Converting Date Format:
QDate da=QDate::fromString(dd,"dd-MM-yyyy");
Shouldn't it be
QDate da=QDate::fromString(dd,"yyyy-MM-dd");
?
Your string is "2018-08-01" and not "01-08-2018"... -
@jsulm oh yes that was so silly thanks but my output now is 01/08/18 this ,what abt last one yyyy ?
@Vineela You can convert your date to whatever string you want.
http://doc.qt.io/qt-5/qdate.html#toString-2 -
@jsulm oh yes that was so silly thanks but my output now is 01/08/18 this ,what abt last one yyyy ?
-
@Vineela
As @jsulm has just stated, you now have an issue about your date output format not the input you converted from. Look through the documentation of http://doc.qt.io/qt-5/qdate.html#toString, i.e.toString()
notfromString()
.