MySQL TIMESTAMP to QDateTime with milliseconds

后端 未结 2 860
既然无缘
既然无缘 2020-12-20 12:16

If I use a QSqlTableModel to access a MySQL database I can convert a TIMESTAMP field using the following:

QDateTime dateTime = index(section, column).data().         


        
2条回答
  •  执笔经年
    2020-12-20 13:05

    From MySQL 5.1 documentation:

    A DATETIME or TIMESTAMP value can include a trailing fractional seconds part in up to microseconds (6 digits) precision. Although this fractional part is recognized, it is discarded from values stored into DATETIME or TIMESTAMP columns.

    It seems like seconds is the best you can do with timestamp.

提交回复
热议问题