As I said in title I need to convert seconds to hh:mm:ss
I tried this:
ui->label->setText(QDateTime::fromTime_t(10).toString("hh:mm:ss"));
But default value for hours is always 01 but I need it to be 00. As result I should get 00:00:10 but I get 01:00:10.
Your timezone is included in it thats why. Try this:
QDateTime::fromTime_t(10).toUTC().toString("hh:mm:ss");
There is no QTime::fromTime_t
; possibly you're using QDateTime::fromTime_t
, which accounts for time zones and daylight savings.
Instead you can use QTime().addSecs(10).toString(...)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With