Below is a sample input/output of this program.

sample base conversion output
Previous Page

Date input manipulation and conversion to integer
C++ console

Copy and Paste the following code into your favorite C++ Integrated Development Environment (IDE) - compile and run.
NOTE: You can use this for time, also. Simply change the hyphens in lines 26 -29 to colons. Or, any delimeter you choose.

/*  Description: This program takes the user's input as a string, separates each individual
                 part of the date from the delimeter, and converts them into integer form. */

#include <iostream>
#include <sstream>// needed for the istringstream to manipulate a string as an input stream                                                        
#include <string>
#include <stdlib.h>// needed for the atoi function that casts a string into an integer

using namespace std;

int main()
    cout << "Enter a date using the following format: 11-10-2011"
         << endl;// tell user to enter the date and what format to use

    string date, month, day, year;// variables for the input of the date. Also, for when
                                  // the date gets separated into individual parts.

    int m, d, y;// will be the integer values for the separated string variables

    getline( cin, date);//get the users input for the date and store it in the variable date

/****************************** manipulate the string date ***************************/
    istringstream separate(date);

    getline(separate, month, '-');// gets the input from the string stream up until the
                                  // '-' character and sets it equal to the month
    getline(separate, day, '-');
    getline(separate, year, '-');
/****************************** convert string to integer values *********************/
    m = atoi(month.c_str());// casts the string month into the integer m
    d = atoi(day.c_str());
    y = atoi(year.c_str());

/****************************** sample outputs ****************************************/

    endl (cout);
    endl (cout);
    cout << "This is the original date:" << date << endl;
    endl (cout);
    cout << "This is the month: " << m << endl;
    cout << "This is the day: " << d << endl;
    cout << "This is the year: " << y << endl;

    return 0;