Python - QDate to datetime conversion

3

I need to convert a date input by a QCalendar to datetime (from the datetime lib). How can I do it?

    
asked by anonymous 24.07.2017 / 19:39

1 answer

3

QDateTime has a toPyDateTime function that returns a datetime

from PyQt5.QtCore import QDate, QDateTime

#usando Date
QDate.currentDate().toPyDate()
datetime.date(2017, 3, 17)

#usando DateTime
QDateTime.currentDateTime().toPyDateTime()
datetime.datetime(2017, 3, 17, 19, 9, 45, 974000)
    
24.07.2017 / 19:54