title: How to turn Python integer into datetime
body: <p>I have a simple PyQt GUI which gives values which I would like to turn into a datetime format.</p>
  
  <p>At the moment it is printing </p>
  
  <pre><code>201011
  </code></pre>
  
  <p>Whereas I would like it to print</p>
  
  <pre><code>2010,1,1
  </code></pre>
  
  <p>Here is the PyQt code,</p>
  
  <pre><code>*timer.py
  from PyQt4 import QtCore, QtGui
  
  try:
      _fromUtf8 = QtCore.QString.fromUtf8
  except AttributeError:
      def _fromUtf8(s):
          return s
  
  try:
      _encoding = QtGui.QApplication.UnicodeUTF8
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig, _encoding)
  except AttributeError:
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig)
  
  class Ui_Dialog(object):
      def setupUi(self, Dialog):
  
          Dialog.setObjectName(_fromUtf8("Dialog"))
          Dialog.resize(510, 129)
          self.gridLayout = QtGui.QGridLayout(Dialog)
          self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
          self.frame = QtGui.QFrame(Dialog)
          self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
          self.frame.setFrameShadow(QtGui.QFrame.Raised)
          self.frame.setObjectName(_fromUtf8("frame"))
          self.gridLayout_2 = QtGui.QGridLayout(self.frame)
          self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
          self.yearlabel = QtGui.QLabel(self.frame)
          self.yearlabel.setObjectName(_fromUtf8("yearlabel"))
          self.gridLayout_2.addWidget(self.yearlabel, 0, 0, 1, 1)
          self.monthfromcomboBox = QtGui.QComboBox(self.frame)
          self.monthfromcomboBox.setObjectName(_fromUtf8("monthfromcomboBox"))
          self.gridLayout_2.addWidget(self.monthfromcomboBox, 1, 2, 1, 2)
          self.label_2 = QtGui.QLabel(self.frame)
          self.label_2.setObjectName(_fromUtf8("label_2"))
          self.gridLayout_2.addWidget(self.label_2, 0, 4, 1, 1)
          self.SearchButton = QtGui.QPushButton(self.frame)
          self.SearchButton.setObjectName(_fromUtf8("SearchButton"))
          self.gridLayout_2.addWidget(self.SearchButton, 2, 4, 1, 2)
          self.yearfromcomboBox = QtGui.QComboBox(self.frame)
          self.yearfromcomboBox.setObjectName(_fromUtf8("yearfromcomboBox"))
          self.gridLayout_2.addWidget(self.yearfromcomboBox, 1, 0, 1, 2)
          self.dayfromcomboBox = QtGui.QComboBox(self.frame)
          self.dayfromcomboBox.setObjectName(_fromUtf8("dayfromcomboBox"))
          self.gridLayout_2.addWidget(self.dayfromcomboBox, 1, 4, 1, 2)
          self.label = QtGui.QLabel(self.frame)
          self.label.setObjectName(_fromUtf8("label"))
          self.gridLayout_2.addWidget(self.label, 0, 2, 1, 1)
          self.gridLayout.addWidget(self.frame, 0, 0, 1, 1)
  
          self.retranslateUi(Dialog)
          QtCore.QMetaObject.connectSlotsByName(Dialog)
          Dialog.setTabOrder(self.yearfromcomboBox, self.monthfromcomboBox)
          Dialog.setTabOrder(self.monthfromcomboBox, self.dayfromcomboBox)
  
      def retranslateUi(self, Dialog):
          Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
          self.yearlabel.setText(_translate("Dialog", "Year", None))
          self.label_2.setText(_translate("Dialog", "Day", None))
          self.SearchButton.setText(_translate("Dialog", "Go", None))
          self.label.setText(_translate("Dialog", "Month", None))
  </code></pre>
  
  <p>The corresponding python code is,</p>
  
  <pre><code>import sys
  import datetime
  from PyQt4 import QtCore, QtGui
  from timer import *
  from PyQt4.QtGui import (QApplication, QTabWidget, QWidget,
                       QStyle, QStyleFactory)
  class Window(QtGui.QDialog):
  
  
      def __init__(self, parent=None):
          QtGui.QWidget.__init__(self, parent)
          self.ui = Ui_Dialog()
          self.ui.setupUi(self)
  
          style = QStyleFactory.create('Cleanlooks')
          app.setStyle(style)
  
          QtCore.QObject.connect(self.ui.SearchButton, QtCore.SIGNAL('clicked()'), self.search)
  
          months = range(1,13)
          for iitem in months:
              Months = str(iitem)
              self.ui.monthfromcomboBox.addItem(Months)
  
          days = range(1,32)
          for iitem in days:
              Days = str(iitem)
              self.ui.dayfromcomboBox.addItem(Days)
  
  
  
          years = range(2010, 2017)
          for iitem in years:
              Years = str(iitem)
              self.ui.yearfromcomboBox.addItem(Years)
  
  
       def search(self):
               nowyear = int(self.ui.yearfromcomboBox.currentText())
               nowmonth = int(self.ui.monthfromcomboBox.currentText())
               nowday = int(self.ui.dayfromcomboBox.currentText())
  
               nowdate = int('%d%d%d' %(nowyear,nowmonth,nowday))
               print nowdate
  
  if __name__ == "__main__":
  
      app = QtGui.QApplication(sys.argv)
      viewer = Window()
      viewer.show()
      sys.exit(app.exec_())
  </code></pre>