QT QDateTime 计算两个日期时间差


1、计算两个日期天数差 1 QDateTime time1 = QDateTime::frString("20201126 16:40:02", "yyyyMMdd hh:mm:ss"); 2 //QDateTime time2 = QDateTime::frString("20201126 16:43:02", "yyyyMMdd hh:mm:ss"); 3 QDateTime time2 = QDateTime::currentDateTime(); 4 int days = time1.daysTo(tim2); 5 qDebug() << "time2 time1=" << days ;

2、计算两个日期分钟差

1 QDateTime time1 = QDateTime::frString("20201126 16:40:02", "yyyyMMdd hh:mm:ss"); 2 QDateTime time2 = QDateTime::frString("20201126 16:43:02", "yyyyMMdd hh:mm:ss"); 3 int minutes = time1.secsTo(tim2); 4 qDebug() << "time2 time1=" << minutes ;



上一篇:VisionPro 图像预处理工具

下一篇:Cognex InSight 相机的连接与仿真的使用


Qt
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图