Pyqt5-dateTimeEdit (date and time)

Source: Internet
Author: User
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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.