Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Wrong Time Zone
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();
Thanks for your reply.
timeZone() in timestamp.timeZone() doesn't come up and gives an error.
mcosta last edited by
Hi and welcome to devnet,
build error or runtime error?
Could you post the error?
For the future - if you get an error you should post what it says. We don't have a crystal ball you know ;)
This post is deleted!