View Full Version : Get the UTC time's problem
hiuao
22nd May 2007, 11:45
As the following I want to get the UTC time's hour minute and second per second.But the result is:0:0:0.Can anybody tell me what to do?
Thank you very much!
QDateTime gmtDateTime;
gmtDateTime.setTimeSpec(Qt::UTC);
QTime UtcTime = gmtDateTime.time();
m_iHour = UtcTime.hour();
m_iMinute = UtcTime.minute();
m_iSecond = UtcTime.second();
high_flyer
22nd May 2007, 11:58
What happens if you do:
QTime UtcTime = QDateTime::currentDateTime ().toTimeSpec();
hiuao
22nd May 2007, 12:18
What happens if you do:
QTime UtcTime = QDateTime::currentDateTime ().toTimeSpec();
Thank you high_flyer for your help.But there is an error:
conversion from `QDateTime' to non-scalar type `QTime' requested.
What's its meaning?
hiuao
22nd May 2007, 12:27
I have tried as the following,but the result isn not UTC time,it's current local time.
QDateTime gmtDateTime = QDateTime::currentDateTime();
gmtDateTime.toTimeSpec(Qt::UTC);
QTime UtTime = gmtDateTime.time();
high_flyer
22nd May 2007, 12:28
oops sorry, I fotgot to convert to QTime:
QTime UtcTime = QDateTime::currentDateTime ().toTimeSpec(Qt::UTC).time();
hiuao
22nd May 2007, 12:38
oops sorry, I fotgot to convert to QTime:
QTime UtcTime = QDateTime::currentDateTime ().toTimeSpec(Qt::UTC).time();
Thank you high_flyer!
It can run correctly!:p
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.