ivaniv1988
ivaniv1988

Reputation: 7

How to display timestamp on QT correctly?

I try to get current time (timestamp) on qt.

myvar1=QDateTime::currentMSecsSinceEpoch();
qDebug()<<myvar1;

In Aplication Output i see strage symbols like | â É etc. I expect 1407112707. So my timestamp is not correct. How to display timestamp on QT correctly?

Upvotes: 0

Views: 1366

Answers (1)

Ezee
Ezee

Reputation: 4344

Possible reason is that you've declared myvar1 incorrecly. Declare it as quint64.

quint64 myvar1 = QDateTime::currentMSecsSinceEpoch();
qDebug() << myvar1;

Also you can use QString::number(myvar1); to get a string representation.

Upvotes: 2

Related Questions