#include <QString>
#include <QDebug>
#include <QTime>
/****************************************************************
* Format a number to the formation Hour:Minute:Second type.
* **************************************************************/
QString formatNumberToHourMinuteSecond(int num)
{
QString ft = "00:00";
if(num >= 0 && num < 60) // 0~60s
{
ft = "00:" + (num/10 >= 1 ? QString::number(num):"0" + QString::number(num));
}
else if(num >= 60 && num < 3600) //60~1h
{
ft = (num/60 >= 10 ? QString::number(num/60):"0" + QString::number(num/60)) + ":"
+ (num%60 >=10 ? QString::number(num%60):"0" + QString::number(num%60));
}
else if(num >= 3600 && num < 86400 ) // 1h~ 24h
{
ft = (num
时间值转换为时分秒格式的字符串
最新推荐文章于 2022-02-18 20:35:49 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)