Abstract system date in C++

35 pts.
Tags:
C
Java classes
VB 6
VB6.0
Visual Basic 6
hi, iam rakesh a MCA student .iwant to abstract system date and time in my c++ project,what should be method for this .please give specific code.
ASKED: March 13, 2009  11:29 AM
UPDATED: March 13, 2009  2:51 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you want to retrieve the current system date and time (and you are on a windows system), you could use the GetLocalTime function.

Here is an example:

<pre>SYSTEMTIME time;

GetLocalTime (&time);</pre>

The SYSTEMTIME structure represents a date and time using individual members for the month, day, year, weekday, hour, minute, second, and millisecond.

<pre>typedef struct _SYSTEMTIME { // st
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME; </pre>

Other option, that will work on non-windows systems is to use the functions from time.h

Example:

<pre>#include <time.h>

void main( int argc, char *argv[] )
{
time_t t;
time(&t);


}</pre>

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following