Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I get QDateTime to return the time in second and micro second

How can I get QDateTime to return the time in second and micro second

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtime
6 Posts 3 Posters 5.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • FlacoDanzigerF Offline
    FlacoDanzigerF Offline
    FlacoDanziger
    wrote on last edited by
    #1

    I am trying to replace ACE_Time_Value and I want to print the current time as <second>.<microsecond> .
    QDateTime has a function currentMSecsSinceEpoch() which return the time in millisecond. but I need a more refine the millisecond.

    kshegunovK 1 Reply Last reply
    0
    • G Offline
      G Offline
      Gerd
      wrote on last edited by
      #2

      You can use
      QDateTiem dateTimeObject;
      dateTimeObject.toString("ss.zzz");

      Regards
      Gerd

      1 Reply Last reply
      0
      • FlacoDanzigerF Offline
        FlacoDanzigerF Offline
        FlacoDanziger
        wrote on last edited by
        #3

        @Gerd said:

        zzz

        The zzz is in millisecond. I need it in Microsecond

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Gerd
          wrote on last edited by
          #4

          Milliseconds is the max resolution of QTime/QDateTime objects. I suspect you have to do your own implementation of a time-class if you need a higher resolution.
          Regards
          Gerd

          1 Reply Last reply
          0
          • FlacoDanzigerF FlacoDanziger

            I am trying to replace ACE_Time_Value and I want to print the current time as <second>.<microsecond> .
            QDateTime has a function currentMSecsSinceEpoch() which return the time in millisecond. but I need a more refine the millisecond.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @FlacoDanziger

            http://doc.qt.io/qt-5/qelapsedtimer.html

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            0
            • FlacoDanzigerF Offline
              FlacoDanzigerF Offline
              FlacoDanziger
              wrote on last edited by
              #6

              Thanks for you response

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved