Wrong Time Zone
General and Desktop
6
Posts
3
Posters
1.8k
Views
3
Watching
-
I've got the following code
QDateTime timestamp = QDateTime::currentDateTime(); timestamp.setTimeSpec(Qt::LocalTime); text = timestamp.toString("hh:mm:ss");But the result shows UTC instead of my timezone. I'm using Win7 and I have the correct timezone listed. Any idea what the problem is?
-
currentDateTimereturns time already in local time spec/zone, so the next line does nothing. Verify if the correct time zone/spec is used e.g. by printing:qDebug() << timestamp.timeZone().displayName(timestamp) << timestamp.timeSpec(); -
Did you
#include <QTimeZone>?
For the future - if you get an error you should post what it says. We don't have a crystal ball you know ;)