QDateTime计算时间差

发布时间 2023-04-02 18:04:04作者: 西北逍遥

QDateTime计算时间差

from PyQt5.QtCore import QDateTime

# Create two QDateTime objects
dt1 = QDateTime.currentDateTime()
dt2 = QDateTime(2022, 1, 1, 0, 0)

# Calculate the difference in seconds
diff_seconds = dt1.secsTo(dt2)

print(f'The difference in seconds is {diff_seconds}')

 

 

#####################