Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Converting Unix Time given in string to QDateTime

From Wiki
Jump to: navigation, search

The code snippet shows how we can convert a unix time value stored in a QString to a corresponding value in QDateTime.

Article Metadata
Tested with
SDK: Nokia Qt SDK 1.1.3
Devices(s): N9, N950
Compatibility
Platform(s): Qt, all versions
Symbian
Article
Keywords: QDateTime
Created: vineet.jain (15 Dec 2011)
Last edited: hamishwillee (11 Oct 2012)

Headers required

#include <QDateTime>

Source

bool isconverted;
QString iUnixTimeValue = "1323275400"
uint iunixtime_integer = iUnixTimeValue .toUInt(&isconverted);
QDateTime idatetime = QDateTime::fromTime_t(iunixtime_integer );

Postconditions

The unix time value got successfully converted to : 07 Dec 2011 16:30:00

This page was last modified on 11 October 2012, at 01:16.
43 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×