QString和QDateTime之间的相互转换

1、QDateTime 转换为QString

QString strBuffer;  
QDateTime time;  
  
time = QDateTime::currentDateTime();  
  
strBuffer = time.toString("yyyy-MM-dd hh:mm:ss");  
  
// strBuffer = 2018-06-06 14:05:00  

2、QString 转换为 QDateTime

QString strBuffer;  
QDateTime time;  
  
strBuffer = "2018-06-06 14:05:00";  
  
time = QDateTime::fromString(strBuffer, "yyyy-MM-dd hh:mm:ss");  

https://blog.csdn.net/coderwu/article/details/5709803


你可能感兴趣的:(QT,C++/C)