Time is early in program . C

Asked

Viewed 130 times

5

I have an application in .c, I finished it but I have a problem with the time. Example: I am recording everything that is done with date and time only the time is early. When I do an operation at 12:54 the time shown is 15:54:16, below is the code:

Note: the time of the computer is correct.

SYSTEMTIME str_t;
GetSystemTime(&str_t);

After that access to the information, and the str_t in the debug Already this with the wrong time.

1 answer

8


According to the documentation of this function return is made on time UTC (that in the background is the GMT time) and your computer is probably on Brasilia time which is three hours late. So you’re getting the time right, you’re just forgetting that you need to treat it properly for what you want, i.e., apply the time zone.

On the other hand if you want to catch local time use the correct function, in case the GetLocalTime().

  • I understood, how I would do this treatment in . c?

  • Edited to indicate the correct solution.

  • Perfect, that’s what I wanted! Very simple rsss. I will mark as correct, but I have to wait 2 min...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.