user1871869
user1871869

Reputation: 3367

QDate into QString

I have a question about PyQt4. I have a date that is of a type QDate and I want to simply turn it into a string format as opposed to QDate format. For example, if the date is 09/16/2013, I would want to change it into a string form of September 16, 2013 if possible.

I played around with toString but I think that only works with C++ (unless I am mistaken).

Upvotes: 1

Views: 10644

Answers (1)

Viktor Kerkez
Viktor Kerkez

Reputation: 46576

Documentation is your friend ;)

>>> date = QtCore.QDate.fromString('20130916', 'yyyyMd')

# PySide
>>> date.toString('MMMM d, yyyy')
u'September 16, 2013'

# PyQt4
>>> date.toString('MMMM d, yyyy')
PyQt4.QtCore.QString(u'September 16, 2013')
>>> unicode(date.toString('MMMM d, yyyy'))
u'September 16, 2013'

Upvotes: 5

Related Questions