how to get the system time
I use the visual c++
and I have a structure :
struct time
{int hours ;
int minutes ;
int seconds ;
} ;
now how do I read the system time and put it into that structure
I already found how to read the system time and put it into a string, but I need it in that srtucture, so I can acces the hours, minutes and seconds by themself
thanx in advance
Why not use the SYSTEMTIME structure:
SYSTEMTIME st;
GetSystemTime (&st);
cout << st.wHour << '':'' << st.wMinute << '':'' << st.wSecond;
SYSTEMTIME st;
GetSystemTime (&st);
cout << st.wHour << '':'' << st.wMinute << '':'' << st.wSecond;
The system time (returned by GetSystemTime()) is expressed in Coordinated Universal Time (UTC), use GetLocalTime() instead (works the same way).
quote:From MSDN:GetSystemTime
This function retrieves the current system date and time. The system time is expressed in Coordinated Universal Time (UTC).
You need to find the offset of your timezone from UTC. As always, the full documentation can be found at MSDN.
How about getting the localtime() instead of getting system time and converting it according to local timezone?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement