We help IT Professionals succeed at work.

How do I parse system time into int variables?

shaolinfunk
shaolinfunk asked
on
If I get the system time like so,

SYSTEMTIME st;
GetLocalTime(&st);

How do I store the Hour, Minute, and Second into integer variables intHour, intMinute, and intSecond?
Comment
Watch Question

C# ASP.NET Developer
Top Expert 2010
Commented:
     SYSTEMTIME st;
      GetLocalTime(&st);
      int hour = st.wHour;
      int minute = st.wMinute;
      int second = st.wSecond;
Commented:
SYSTEMTIME contains all that:
SYSTEMTIME st;
GetLocalTime(&st);
int nHours = st.wHour;
int nMinutes = st.wMinute;
int nSeconds = st.wSecond;

SYSTEMTIME st;
GetLocalTime(&st);

intHour = st.wHour;
intMinute = st.wMinute;
intSecond = st.wSecond;

Open in new window