Ejaz
Ejaz

Reputation: 1632

QDate.currentDate() display formatting

I need the date in a regular form.

Here when I use the below code:

import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *

date = QDate.currentDate()
print date

I get the below output:

PyQt4.QtCore.QDate(2014, 5, 23)

I want the date to be displayed in '/' or '.' eg.(5.23.2014)

Please suggest how to do it.

Upvotes: 0

Views: 2180

Answers (1)

Padraic Cunningham
Padraic Cunningham

Reputation: 180401

Check the docs:

date = QDate.currentDate().toString("dd.MM.yyyy")
print date
2014.5.23

To change:

date = QDate.currentDate().toString("MM.dd.yyyy")
print date
05.23.2014

Upvotes: 2

Related Questions