문제

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

도움이 되었습니까?

해결책

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 );
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top