Convert QString Unix era to standard QString time

I need an elegant C ++ function that takes a QString parameter containing unix time (e.g. 1295874681) and converts it to a standard time format (e.g. Mon, Jan 24, 2011 1:11:21 PM GMT) containing QString and returns it .

+4
source share
1 answer
bool ok; const uint s = unixTimeStr.toUInt( &ok ); if ( !ok ) { ..handle conversion error (unixTimeStr not containing a number) } const QDateTime dt = QDateTime::fromTime_t( s ); const QString textdate = dt.toString( Qt::TextDate ); 
+9
source

Source: https://habr.com/ru/post/1345694/


All Articles