C++ QDateTime是否与时区同步?
我正在寻找来自qt的datetime,以将字符串作为isodate返回给我,但带有时区。 我有时在网上查找我的问题,但没有找到解决办法 我刚得到这个:C++ QDateTime是否与时区同步?,c++,qt,datetime,timezone,C++,Qt,Datetime,Timezone,我正在寻找来自qt的datetime,以将字符串作为isodate返回给我,但带有时区。 我有时在网上查找我的问题,但没有找到解决办法 我刚得到这个: this->ui.dateEnd->dateTime().toString(Qt::ISODate); 给我这个: 1900-10-31T23:00:00Z 1900-10-31T23:00:00Z 或者也包括: this->ui.dateEnd->dateTime().toUfc().toString(Qt::IS
this->ui.dateEnd->dateTime().toString(Qt::ISODate);
给我这个:
1900-10-31T23:00:00Z
1900-10-31T23:00:00Z
或者也包括:
this->ui.dateEnd->dateTime().toUfc().toString(Qt::ISODate);
给我这个:
1900-10-31T23:00:00Z
1900-10-31T23:00:00Z
我想要这个:
1900-10-31T23:00:00+01.00.00
如果有人有想法,谢谢你 绕过了我在评论中提到的错误:
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);
dateTime.toTimeSpecQt::offsetfromtc.toStringQt::ISODate应该根据文档工作,但似乎是这样。