[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

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
0
PX
Asked:
PX
  • 2
1 Solution
 
ndgunCommented:
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now