Qt/C++ - Convert string timestamp to uint -


i want create date timestamp in char*.

so i'm trying convert int atoi() or toint() don't it.

qdebug() << atoi("1478790756754"); /* give 2147483647 */  qstring tmp = "1478790756754"; qdebug() << tmp.toint(); /* give 0 */ 

the aim date, datetime.settime_t() example.

your timestamp seems in milliseconds since 1.1.1970 format. doesn't fit 32-bit integer, int type on architecture.

the solution simple: convert type larger value range, i.e. long long:

qstring tmp = "1478790756754"; qdatetime date = qdatetime::frommsecssinceepoch(tmp.tolonglong()); 

qstring's conversion functions have out parameter pointer bool. can pass bool variable , test check if conversion successful.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -