Search code examples
pythonstringpyqtformatqdate

Change the format of a QDate


I need to change the format of a QDate. Here is my code:

 yday = (QtCore.QDate.currentDate().addDays(-1))

And I got this result...

PyQt4.QtCore.QDate(2015, 4, 2)

But I need the date in this format:

2015/04/03


Solution

  • you can use datetime.strftime()

    yourdate.strftime('%Y, %m, %d')