-
-
Save bigdragon1977/10602235 to your computer and use it in GitHub Desktop.
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
QDateTime timeConvertor; | |
QString customDateString = "14-Nov-2010 05:27:03 +0100"; | |
QString dateTime = customDateString.left(20); | |
int timezoneOffset = customDateString.right(5).left(3).toInt(); | |
timeConvertor = QDateTime::fromString(dateTime, "dd-MMM-yyyy HH:mm:ss"); | |
// Mark this QDateTime as one with a certain offset from UTC, and set that | |
// offset. | |
timeConvertor.setTimeSpec(Qt::OffsetFromUTC); | |
timeConvertor.setUtcOffset(timezoneOffset * 3600); | |
// Convert this QDateTime to UTC. | |
timeConvertor = timeConvertor.toUTC(); | |
// Store the UTC timestamp. | |
int timestamp = timeConvertor.toTime_t(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment