Display Date and Time in C++

This tip submitted by Govind on 2009-07-28 04:35:35. It has been viewed 30992 times.
Rating of 5.8 with 382 votes

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


void main()
  struct dosdate_t govind;
  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!