Clock in milliseconds

This is a discussion on Clock in milliseconds within the C++ Programming forums, part of the General Programming Boards category; Hi, im writing a program that needs the real time (the one u see at the bottom right of the ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    110

    Clock in milliseconds

    Hi, im writing a program that needs the real time (the one u see at the bottom right of the screen) in milliseconds. So if its 10:51 AM it would return whatever ((10*60)*60)*1000+(51*60)*1000 is. I looked at the tutorial but wasnt sure how I could get the time.

    Im using windows XP and vs.net Dos would be great but not required

  2. #2
    Banned
    Join Date
    Jun 2005
    Posts
    594
    GetTickCount returns milliseconds, its got a +/- 10 millisecond
    return rate.

    google the function to figure out how to apply it to
    your situation.

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    my program looks like this.

    Code:
    int main()
    {
    
       DWORD time = GetTickCount();
        cout << "Time: " << time << endl ;
    
    
      system("pause");
      return EXIT_SUCCESS;
    }
    It returned

    Time: 265014671

    which is 265,014,671


    at about 12:00 AM.

    According to my calculatoions. 12 AM is 43,200,000


    Is there something im doing wrong?

  4. #4
    myNegReal
    Join Date
    Jun 2005
    Posts
    100
    Starting from what though? The beginning of the day? When the computer was turned on? Program start? If you turn a computer on at exactly 11:59, then 12:00 should return 1000 milliseconds. But if it's turned on at 8:00 then at 12:00 it should return (60*(60*1000))*4 = a very large amount of milliseconds(from point of view of how much time passed by since computer start).
    Using Dev-C++ on Windows

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    Ah ........!, ok thnx. I need to find out how to get the time in milliseconds. Like right now its 12:56. How do I detect that ?

  6. #6
    Registered User
    Join Date
    Jul 2005
    Posts
    69
    SYSTEMTIME GetSystemTime GetLocalTime Never really tried this for milliseconds though it looks like their stored. Sorry for replying to C++, just following the thread.
    Regards,
    Brian

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical Error in Clock program
    By SVXX in forum C++ Programming
    Replies: 0
    Last Post: 05-10-2009, 01:12 AM
  2. Outside influences on clock cycles? (clock_t)
    By rsgysel in forum C Programming
    Replies: 4
    Last Post: 01-08-2009, 06:15 PM
  3. Clock Troubles
    By _Nate_ in forum C Programming
    Replies: 22
    Last Post: 06-19-2008, 06:15 AM
  4. clock program
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 03-30-2007, 11:12 PM
  5. Milliseconds
    By Magos in forum C++ Programming
    Replies: 8
    Last Post: 11-01-2001, 03:13 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21