GetSystemTime

This is a discussion on GetSystemTime within the Windows Programming forums, part of the Platform Specific Boards category; I am facing some problem in displaying system time. When It display in message box, it is different from the ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    175

    GetSystemTime

    I am facing some problem in displaying system time. When It display in message box, it is different from the time shown on PC at botton right corner.

    Could you please guide me.

    Here is code.
    Code:
    SYSTEMTIME st;
    	char buf[80];
    
    		
    	GetSystemTime(&st);
    
    	sprintf(buf,"%d:%d:%d ",st.wHour, st.wMinute, st.wMilliseconds);
    
    	//GetTimeFormat( 0, 0, &st, "hh':'mm':'ss tt", buf, sizeof(buf) );
                  MessageBox( NULL, buf, " SYSTEM TIME", MB_OK );

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361

    Re: GetSystemTime

    Originally posted by Roaring_Tiger
    I am facing some problem in displaying system time. When It display in message box, it is different from the time shown on PC at botton right corner.

    Could you please guide me.

    Here is code.
    Code:
    SYSTEMTIME st;
    	char buf[80];
    
    		
    	GetSystemTime(&st);
    
    	sprintf(buf,"%d:%d:%d ",st.wHour, st.wMinute, st.wMilliseconds);
    
    	//GetTimeFormat( 0, 0, &st, "hh':'mm':'ss tt", buf, sizeof(buf) );
                  MessageBox( NULL, buf, " SYSTEM TIME", MB_OK );
    The system can periodically refresh the time by synchronizing with a time source. Because the system time can be adjusted either forward or backward, do not compare system time readings to determine elapsed time. Instead, use one of the methods described in Windows Time.

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    9
    Try using GetLocalTime instead of GetSystemTime.

    Good luck,
    Chris

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GetSystemTime and my current time
    By Joelito in forum Windows Programming
    Replies: 2
    Last Post: 09-20-2005, 07:57 PM
  2. GetLocalTime & GetSystemTime ?
    By SAMSAM in forum Windows Programming
    Replies: 9
    Last Post: 02-05-2003, 02:27 AM
  3. timeGetTime(), getSystemTime(), GetTickCount()
    By Shadow12345 in forum Windows Programming
    Replies: 1
    Last Post: 11-02-2002, 10:35 AM

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