#include <iostream>
#include <ctime>
using namespace std;

/* From Open C++ FAQ: how do I get the current time and date? */
/* Reference: http://www.cpp-home.com/faq/faq.pl?63 */

int main()
{
  time_t mytime;
  time(&mytime);

  cout << "Current date and time is: " << ctime(&mytime) << endl;

  struct tm* times;
  times = localtime(&mytime);
  cout << "tm_sec: " << times->tm_sec << endl;
  cout << "tm_min: " << times->tm_min << endl;
  cout << "tm_hour: " << times->tm_hour << endl;
  cout << "tm_mday: " << times->tm_mday << endl;
  cout << "tm_mon: " << times->tm_mon << endl;
  cout << "tm_year: " << times->tm_year << endl;
  cout << "tm_wday: " << times->tm_wday << endl;
  cout << "tm_yday: " << times->tm_yday << endl;
  cout << "tm_isdst: " << times->tm_isdst << endl;
  cout << "The time is: " << times->tm_hour << ":" 
    << times->tm_min << ":" << times->tm_sec << endl;
  cout << "The date is: " << times->tm_mday << "-"
    << times->tm_mon+1 << "-" << times->tm_year+1900 << endl;

  return 0;
}


