0

here is my test code,

            utc_fmt = "yyyy/MM/dd hh:mm:ss.zzzzzz"
            new_date = QDateTime().fromString("2023/01/01 20:19:18.171123", utc_fmt)
            debug =new_date.toString("yyyy/MM/dd hh:mm:ss.zzzzzz")
            print("time:"+debug)

conversion seems failed,

When I changed the format to

utc_fmt = "yyyy/MM/dd hh:mm:ss.zzz"
#...
debug =new_date.toString("yyyy/MM/dd hh:mm:ss.zzz")

conversion succeeded.

Does that mean QDateTime will not support ss.zzzzzz(six digits after point, microseonds)?

Rui
  • 97
  • 1
  • 8
  • 1
    The expressions in the [documentation](https://doc.qt.io/qt-5/qtime.html#fromString-1) are not variable quantifiers, they are literal. The only valid formats for fractions of seconds are `z` and `zzz`. If you need microsecond precision, just format up to the second, and append the rest to the resulting string. – musicamante Mar 13 '23 at 14:15
  • Got it, microsec precision encountered another problem too, when I tried to use toSecsSinceEpoch() function (err: Python int too large to convert to C long). Thanks for your suggestions. – Rui Mar 13 '23 at 14:36

0 Answers0