Display Date and Time in C++

This tip submitted by Govind on 2009-07-28 04:35:35. It has been viewed 13795 times.
Rating of 6.4 with 238 votes



Here is some sample code that shows how to get the date and time on a DOS system.

#include
#include
#include

void main()
{
  struct dosdate_t govind;
  _dos_getdate(&govind);
  clrscr();
  printf("The current year is: %d\n", govind.year);
  printf("The current day is: %d\n", govind.day);
  printf("The current month is: %d\n", govind.month);
}




More tips

Help your fellow programmers! Add a tip!