Results 1 to 9 of 9

Thread: Get # of sec since midnight

  1. #1

    Thread Starter
    Addicted Member Cuallito's Avatar
    Join Date
    Apr 2001
    Location
    You know that chest that you could never get opened? If you ever do, I'm there.
    Posts
    136

    Get # of sec since midnight

    I am using Win 98 with Microsof Visual C++ 6.0. How can I get the number of seconds since midnight?
    BTW, Thanks for all your help

    Member of the anti-gay cross-dressing trans-species wolves alliance.

  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    GetTickCount counts the milliseconds since you computer's been on....turn it on a midnight just kidding!

    the Time API will give you the time....I've never really used it so I can't tell you what math you'd need after that but you should be able to figure it out....I'll do one now....it seems interresting! (a huge number too considering its 11:36 pm now!)


  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Well it is not a huge number as you say because in 24 hrs there are 86400 seconds, and that can easily be put into an integer.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4

    Thread Starter
    Addicted Member Cuallito's Avatar
    Join Date
    Apr 2001
    Location
    You know that chest that you could never get opened? If you ever do, I'm there.
    Posts
    136
    Hey i'm new to C++. BTW, this is a console program. How do I do it?
    BTW, Thanks for all your help

    Member of the anti-gay cross-dressing trans-species wolves alliance.

  5. #5
    Lively Member
    Join Date
    Dec 2000
    Location
    Indiana
    Posts
    73
    Even though you're using console, you can still use the Win32 API (as long as its a Win32 Console, and not a DOS program).

    Just include windows.h> and use whatever you want

  6. #6
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Well I'm saying it would be huge compared the the total...since there were only a few minutes left in the day...btw how do you use time.h? This thread got me interrested in doing this but I keep getting the same #

  7. #7
    Megatron
    Guest
    Originally posted by Vlatko
    Well it is not a huge number as you say because in 24 hrs there are 86400 seconds, and that can easily be put into an integer.
    It would have to be in a long, rather than an int, because the int (unsigned) can only store up to 65535.

  8. #8
    jim mcnamara
    Guest
    Here's code that works....
    PHP Code:
    #include <windows.h>
    #include <stdio.h>
    void main(void){
        
    long elapsed =0;
        
    // Create system time structure
        
    SYSTEMTIME *SystemTimeSys;
        
    SystemTime = &Sys;
        
    GetLocalTime(SystemTime);
        
    elapsed SystemTime->wSecond;
        
    elapsed += (SystemTime->wMinute 60);
        
    elapsed += (SystemTime->wHour 3600);
        
    printf("Secs since midnight %d\n",elapsed);    



  9. #9
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Megatron integers are 4 butes long in C++ so an integer can hold values from –2,147,483,648 to 2,147,483,647. Long is also an integer (long integer) but it has the same range as an integer.
    Unsigned short int can hold values up to 65535 not just an integer.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width