Created
March 1, 2018 03:43
-
-
Save jniemann66/075a57983148b9178be200741b7ae7b4 to your computer and use it in GitHub Desktop.
Qt: Convert QDateTime to ISO Date Time with Timezone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get timezone offset in seconds | |
int offsetSeconds = QTimeZone::systemTimeZone().offsetFromUtc(QDateTime::currentDateTime()); | |
// format an ISO Date & Time with Timezone. eg "2018-03-21T13:04:00+11:00" | |
QDateTime selectedDateTime = QDateTime(calendarWidget->selectedDate(), timeEdit->time(), Qt::OffsetFromUTC, offsetSeconds); | |
qDebug() << selectedDateTime.toString(Qt::ISODate); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I never want to have to solve this again, so putting it in a gist !