Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DISPLAY DATE AND TIME ???

Status
Not open for further replies.

aas1611

Programmer
Dec 14, 2001
184
DE
Hi,

I need some help to display the current DATE and TIME. I just need a simple output. For example if the date is Dec 19, 2001, it's simply printed as 121901. and if the time is 9:15:23, it's printed 091523.
And I need a program that's compatible with DOS 6, 486 processor.

Thank you very much for every answer that leads me to solution!!
Merry Christmas..

Andre
 
The easiest thing to do is use CDate. If you are using a time stamp struct it has a conversion built in. CDate has a Format method which will format the string how you speicify. The help section of vc explains this.

Matt
 
Or use the standard C library:

Code:
#include <time.h>

{
  time_t tLocalTime;
  struct tm* ptMyTime;

  time(&LocalTime);
  pMyTime = localtime(&LocalTime);

  /* if desired, extract the pieces to variables */
  int iHour = pMyTime->tm_hour;

  /* but use sprintf() to format the pieces */
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top