×
Namespaces

Variants
Actions

Converting Unix Time given in string to QDateTime

From Nokia Developer 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 04:16.
86 page views in the last 30 days.
×