QDateTime Isodate with timezone?

I am looking for datetime from qt to return me a string as isodate, but with a timezone. I sometimes looked on the Internet on my problem, but could not find a solution

I just got this:

this->ui.dateEnd->dateTime().toString(Qt::ISODate); 

gives me this:

 1900-10-31T23:00:00Z 

Or also this:

 this->ui.dateEnd->dateTime().toUfc().toString(Qt::ISODate); 

gives me this:

 1900-10-31T23:00:00Z 

I want too:

 1900-10-31T23:00:00+01.00.00 

Thanks if anyone has an idea!

+4
source share
1 answer

Got an error that I mentioned in the comments:

 QDateTime local = QDateTime::currentDateTime(); QDateTime utc = local.toUTC(); utc.setTimeSpec(Qt::LocalTime); int utcOffset = utc.secsTo(local); qDebug() << local.toString(Qt::ISODate); qDebug() << utc.toString(Qt::ISODate); qDebug() << utcOffset; local.setUtcOffset(utcOffset); qDebug() << local.toString(Qt::ISODate); 

It is output:

 "2013-09-12T00:17:39" "2013-09-11T21:17:39" 10800 "2013-09-12T00:17:39+03:00" 
+5
source

Source: https://habr.com/ru/post/1501730/


All Articles