Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save davidas13/7b7fcb9b3592b5a38873aa647c13a15c to your computer and use it in GitHub Desktop.

Select an option

Save davidas13/7b7fcb9b3592b5a38873aa647c13a15c to your computer and use it in GitHub Desktop.
from PyQt5.QtCore import QDate, QTime, QDateTime, Qt
now = QDate.currentDate()
print(now.toString(Qt.ISODate))
print(now.toString(Qt.DefaultLocaleLongDate))
print(now.toString(Qt.DefaultLocaleShortDate))
date_time = QDateTime.currentDateTime()
print(date_time.toString())
time = QTime.currentTime()
print(time.toString(Qt.DefaultLocaleLongDate))
from PyQt5.QtCore import QDateTime, Qt
now = QDateTime.currentDateTime()
print("Local datetime: ", now.toString(Qt.ISODate))
print("Universal datetime: ", now.toUTC().toString(Qt.ISODate))
print("The offset from UTC is: {0} seconds".format(now.offsetFromUtc()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment