linux时间戳与QDataTime 相互转换

作者:fly 发布于:2017-1-9 14:42 分类:Linux

QDataTime转换成时间戳

QDateTime time = QDateTime::currentDateTime();   //获取当前时间  

int timeT = time.toTime_t();   //将当前时间转为时间戳


时间戳转换成QDataTime

QDateTime time = QDateTime::fromTime_t(timeT);


字符串转换成QDataTime

QDate date;  

QTime time;  

QString a = timeString.mid(0,8);  

QString b = timeString.mid(8,6);  

date = QDate::fromString(a,"yyyyMMdd");  

time = QTime::fromString(b,"hhmmss");  

return QDateTime(date,time);")  

发表评论:

 
Powered by emlog sitemap