rajeshs
4th June 2008, 13:18
Hi,
please any one give some way to convert time from Local to UTC and UTC to Local in Qt.
jacek
4th June 2008, 13:48
See QDateTime::setTimeSpec().
rajeshs
5th June 2008, 04:05
actually i tried with setTimeSpec() function, but it is not conveting time from UTC to LocalTime.
jacek
5th June 2008, 11:22
setTimeSpec() doesn't do the conversion, it only tells Qt that the date is in UTC. You also need to call toLocalTime(), toUTC() or toTimeSpec().
QDateTime d( QDate( 2008, 6, 5 ), QTime( 12, 0 ) );
d.setTimeSpec( Qt::UTC );
qDebug() << d << d.toLocalTime();
or
QDateTime d( QDate( 2008, 6, 5 ), QTime( 12, 0 ), QT::UTC );
qDebug() << d << d.toLocalTime();
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.