TheCoffeeCup
TheCoffeeCup

Reputation: 326

How to read timestamp from uint64

I want to read and display a timestamp in mseconds since epoch , which was send from a client application. My code looks like this:

QDateTime timestamp;

timestamp.fromMSecsSinceEpoch(dataBody.timeStamp);
out << "Time Stamp:" + timestamp.toString(Qt::SystemLocaleShortDate) + "\n";

However, the output is "Time Stamp:", and system says that timestamp is invalid. What is wrong with my code?

Upvotes: 0

Views: 1031

Answers (1)

Pavel Strakhov
Pavel Strakhov

Reputation: 40492

Your code shouldn't even compile because QDateTime::fromMSecsSinceEpoch is a static function. Correct usage:

QDateTime timestamp = QDateTime::fromMSecsSinceEpoch(dataBody.timeStamp);

Upvotes: 1

Related Questions