QT两种字符串时间格式的转化

两种字符串时间格式的转化

QT中对字符串时间格式的转化为另一种字符串时间格式

QDateTime makeTime = QDateTime::fromString(QString(“20230102123478”), "yyyyMMddhhmmss");
QString formattedMakeTime = makeTime.toString("yyyy/MM/dd hh:mm:ss");

转化的步骤:

  1. 先将时间字符串转化为时间格式 QString->QDateTime(QDate)
  2. 再将刚刚的时间格式转化为字符串 QDateTime(QDate)->QString

posted on 2024-10-15 16:08  ZanderChan  阅读(71)  评论(0)    收藏  举报

导航