Windows time (VC++ 2010)

I am trying to find out how to get the date (day of week; day of month with 1st, 2nd, etc; month; and year). In Microsoft Visual C++ 2010 Express, the underlined section of the following code gets the error:
int tm::tm wday
Error: a nonstatic member reference must be relative to a specific oject
1
2
3
4
5
6
7
8
#include <iostream>
#include <time.h>
using namespace std;
int main () 
{
	int a;
	a = tm.tm_wday;
}

"a = tm::tm_wday;" gets the same error.
Please help me remove this error.
tm is a struct. You need to create an object to access it's member.
See http://www.cplusplus.com/reference/clibrary/ctime/localtime/ for an example
Look up GetSystemTime() and LPSYSTEMTIME struct.
Use GetLocalTime(). It will give you local system time. If you want time in UTC format use GetSystemTime(). Both function using SYSTEMTIME struct.

Look at http://msdn.microsoft.com/en-us/library/ms724338%28VS.85%29.aspx
Topic archived. No new replies allowed.