Results 1 to 5 of 5

Thread: how to get the current system time ?

  1. #1
    Join Date
    Jan 2010
    Posts
    63
    Qt products
    Qt4
    Platforms
    Windows

    Default how to get the current system time ?

    Using standard C++ functions how can i get the current time from my system since noon?

    I tried:
    Qt Code:
    1. time_t hours;
    2. hours= time(&hours);
    3. last_time=hours-12;
    To copy to clipboard, switch view to plain text mode 
    This won't work.

  2. #2
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to get the current system time ?

    Why dont you use ?
    QTime::currentTime();

  3. #3
    Join Date
    Jan 2010
    Posts
    63
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to get the current system time ?

    That makes it too easy. The idea is not to use it.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to get the current system time ?

    last_time=hours-12;
    Had you provided the necessary overloaded functions ? (-) and mechanism to create object out of numeric value...

  5. #5
    Join Date
    Jan 2010
    Posts
    73
    Thanks
    6
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to get the current system time ?

    Quote Originally Posted by Petr_Kropotkin View Post
    That makes it too easy. The idea is not to use it.
    You want "not easy":

    • Add a camera pointing at a clock, take a picture of the clock, interpret the graphic image as a time.
    • Create a temporary file, take the time from the file.
    • Get the time from a time server

Similar Threads

  1. Current Time in msec accuracy in Qt for WinCE
    By funghy in forum Qt Programming
    Replies: 4
    Last Post: 22nd June 2009, 10:00
  2. displaying system time
    By aj2903 in forum Newbie
    Replies: 4
    Last Post: 2nd December 2008, 06:32
  3. How to display My Current System IP Address...???
    By maveric in forum Qt Programming
    Replies: 8
    Last Post: 4th August 2008, 17:22
  4. Show System Time Stamp ??
    By dheeraj in forum Qwt
    Replies: 3
    Last Post: 21st April 2008, 11:54
  5. Current Time with microsecond precision on windows
    By Dwarf007 in forum General Programming
    Replies: 16
    Last Post: 5th April 2006, 11:42

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.