Hey, I need to find the amount of years, months, and days between two dates. The first date comes from the user while the second is from the current date. I am lost on how to get the month day and year out of ctime. It shows as sep 10 2014 but I need september as a number. My professor hinted at converting the char dt into a string and then using substr to get the values. I can get day and year but I don't know how to get month.
#include <iostream>
#include <ctime>
#include <string>
usingnamespace std;
int main(){
int month;
int day;
int year;
// current date/time based on current system
time_t now = time(0);
// convert now to string form
char* dt = ctime(&now);
//convert dt to string and use substring to get day month and year
string mystring = string(dt);
string strDay = mystring.substr(8,2);
string strYear = mystring.substr(20,4);
//Prompt user to enter date
cout << "Enter the date when the customer opened the account(MM/DD/YYYY): ";
cin >> month >> d >> day >> d >> year;
cout << "Hello world !! Current date and time is: " << dt << endl;
system("Pause");
return 0;
}