Skip to content

Instantly share code, notes, and snippets.

@jniemann66
Created March 1, 2018 03:43
Show Gist options
  • Save jniemann66/075a57983148b9178be200741b7ae7b4 to your computer and use it in GitHub Desktop.
Save jniemann66/075a57983148b9178be200741b7ae7b4 to your computer and use it in GitHub Desktop.
Qt: Convert QDateTime to ISO Date Time with Timezone
// 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);
@jniemann66
Copy link
Author

I never want to have to solve this again, so putting it in a gist !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment