import sys from PySide.QtGui import QApplication, QDateTimeEdit app = QApplication(sys.argv) datetime_edit = QDateTimeEdit() datetime_edit.setDisplayFormat('yyyy-MM-dd hh:mm:ss') datetime_edit.show() sys.exit(app.exec_())
import sys from PySide.QtGui import QApplication, QDateTimeEdit app = QApplication(sys.argv) datetime_edit = QDateTimeEdit() datetime_edit.setDateTime(QDateTime(2022, 12, 25, 12, 0, 0)) print(datetime_edit.dateTime().toString()) sys.exit(app.exec_())In this example, the setDateTime() method is used to set the date and time to December 25th, 2022 at 12:00 PM. The dateTime() method is then called to retrieve the current date and time value displayed in the widget, which is then printed to the console. Package Library: PySide