Invalid date format conversion in Qt

    QDateTime valid = QDateTime::fromString("2018-Apr-5", "yyyy-MMM-d");

use qDebug () output valid to directly say that it is invalid, what is this all about? It is not valid to use an example in the official document:


  QString string = "Tuesday, 23 April 12 22:51:41";
  QString format = "dddd, d MMMM yy hh:mm:ss";
  QDateTime valid = QDateTime::fromString(string, format);

the above paragraph is an example given in the official document. It doesn"t work as long as you use MMM or MMMM .

Mar.04,2021
Menu