Set the time in the UI-***. py file:
1 self. datetimeedit = qtwidgets. qdatetimeedit (self. widget) 2 self. datetimeedit. setframe (false) # Remove the border 3 self. datetimeedit. setdate (qtcore. qdate (2018, 10, 25) # set date 4 self. datetimeedit. settime (qtcore. qtime (11, 0, 0) # set the time 5 self. datetimeedit. setobjectname ("datetimeedit") # Set Object Name 6 7 "8 Mode 1: 9 qtcore. qdate. currentdate () # Set to the current date 10 qtcore. qtime. currenttime () # Set to the current time 11 mode qdatetime. currentdatetime () # set the current date and time 13 """
1 #! /Usr/bin/python3 2 3 from pyqt5.qtcore import qdate, qtime, qdatetime, QT 4 5 now = qdate. currentdate () 6 7 print (now. tostring (QT. isodate) 8 print (now. tostring (QT. defaultlocalelongdate) 9 10 datetime = qdatetime. currentdatetime () 11 12 print (datetime. tostring () 13 14 time = qtime. currenttime () 15 16 print (time. tostring (QT. defaultlocalelongdate) 17 18 "19 in this example, the current date, date and time are printed, and the time 20 21 currentdate () method returns the current date 22 now = qdate. currentdate () 23 24 currenttime () method returns the current time 25 time = qtime. currenttime () 26 27 this date through the method QT. isodate and QT. defaultlocalelongdate is printed in different formats 28 print (now. tostring (QT. isodate) 29 print (now. tostring (QT. defaultlocalelongdate) 30 31 tcurrentdatetime () method returns the current date and time 32 datetime = qdatetime. currentdatetime () 33 34 $. /current_date_time.py 35 2017-09-1136 Monday, September 11,201 737 mon sep 11 12:37:45 201738 12:37:45 PM cest39 this is the output.40 """
Pyqt5-dateTimeEdit (date and time)