Qt 日期时间

1.两个时间戳做减法(差值)   

 QDateTime time1 = QDateTime::fromString("2019-09-19 18:40:02", "yyyy-MM-dd hh:mm:ss");
    
 QDateTime time2 = QDateTime::fromString("2019-09-19 18:43:02", "yyyy-MM-dd hh:mm:ss");
 
   
 qDebug() << "time2 - time1=" << time1.secsTo(time2);

输出为 180,单位为秒

猜你喜欢

转载自www.cnblogs.com/ike_li/p/12222061.html