Auto update date

I'm writing a program just for fun. My program will ask the user the date he would like to finish reading the book and calculate how many chapter or pages he will have to read in order to finish the book on time.

My initial program asks also the date today for the user, but I am just wondering if there is a way to make the program do this without asking the user for the date.

Any thoughts?

Thanks
You can use std::chrono with the older c libraries for time, since the c++ standard, as far as I know, doesn't provide a wrapper for time formatting.

1
2
3
4
  std::time_t time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());

  struct tm *now = localtime(&time);
  std::cout << "Year: " << now->tm_year + 1900 << " Month: " << now->tm_mon + 1 << " Day: " << now->tm_mday << std::endl;

produces
Year: 2016 Month: 9 Day: 6
That's awesome.

Thanks for your input.
Topic archived. No new replies allowed.