Date and time

Hi,

I want to know how to get the system time like year, date and time, i am using Microsoft VC 6, plz help.

Thx
LVL 1
PXAsked:
Who is Participating?
 
ndgunConnect With a Mentor Commented:
You can try the following windows base functions:
GetLocalTime()
GetSystemTime()

You can also try:
CTime::GetCurrentTime()
0
 
PXAuthor Commented:
hi ndgun,

Can u give me a smaple code snipet, thx a lot.
0
 
ndgunCommented:
// example for CTime::GetCurrentTime
CTime t = CTime::GetCurrentTime();

You can look at MSDN for details on CTime class.


If you use the GetSystemTime, you can say
SYSTEMTIME SystemTime;
GetSystemTime(&SystemTime);

Again, MSDN on CD or microsoft website has details of the struct SYSTEMTIME.

typedef struct _SYSTEMTIME {  // st
    WORD wYear;
    WORD wMonth;
    WORD wDayOfWeek;
    WORD wDay;
    WORD wHour;
    WORD wMinute;
    WORD wSecond;
    WORD wMilliseconds;
} SYSTEMTIME;
 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.