Results 1 to 10 of 10

Thread: time in microseconds

  1. #1
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default time in microseconds

    Hi.
    How can i get current time in microseconds but from 1.january.0001. something as .NET MinValue

    i found only this solution.
    std::chrono::time_point<std::chrono::steady_clock> ts = std::chrono::steady_clock::now();
    std::chrono::duration_cast<std::chrono::microsecon ds>(ts.time_since_epoch()).count()+621355968000000 00);
    Last edited by stevocz; 4th November 2016 at 09:43.

  2. #2
    Join Date
    Mar 2014
    Posts
    23
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default Re: time in microseconds

    Well, that's not really a Qt-related question, is it? ;-)

    Most timers are not really accurate down to microseconds. For using chrono I recommend reading this: http://www.informit.com/articles/art...81386&seqNum=2
    You could also have a look at QueryPerformanceFrequency and QueryPerformanceCounter which I find to be more easy-to-use (but at the cost of platform dependency).

  3. #3
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: time in microseconds

    is not really Qt. but i must run this app on SLES 11 SP3 with QT4.6 and there missing chrono. I need find different solution.

  4. #4
    Join Date
    Sep 2016
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: time in microseconds

    interesting.. want to know the answer

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: time in microseconds

    If you were looking for milliseconds, that would be easy with QDateTime::msecsTo().

    Cheers,
    _

  6. #6
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: time in microseconds

    QDateTime::msecsTo() is not awailable in QT4.6, only QTime::msecsTo().
    Last edited by stevocz; 5th November 2016 at 17:50.

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: time in microseconds

    You could do the same as the Qt5 implementation does;
    https://code.woboq.org/qt5/qtbase/sr...e7msecsToERKS_

    Cheers,
    _

  8. #8
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: time in microseconds

    but there is in milliseconds not microseconds

  9. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: time in microseconds

    Quote Originally Posted by stevocz View Post
    but there is in milliseconds not microseconds
    How could I have missed that?
    Oh, wait, I didn't.

    Quote Originally Posted by anda_skoa View Post
    If you were looking for milliseconds
    Though you could just multiply by 1000, as Killian already pointed out it is unlikely that the system has microseconds precision at all.

    Cheers,
    _

  10. #10
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: time in microseconds

    sorry. my mistake

Similar Threads

  1. Replies: 6
    Last Post: 25th June 2015, 10:54
  2. Replies: 5
    Last Post: 19th November 2010, 02:25
  3. Replies: 6
    Last Post: 18th August 2010, 12:52
  4. Get QDate from microseconds
    By iddqd in forum Newbie
    Replies: 7
    Last Post: 20th July 2010, 09:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.